mirror of
https://github.com/tobiasehlert/teslamateapi.git
synced 2026-02-27 09:54:18 +08:00
moving defer to when error check has passed
go-staticcheck: should check returned error before deferring commandAllowListFile.Close() (SA5001)
This commit is contained in:
@@ -140,10 +140,10 @@ func initCommandAllowList() {
|
||||
if len(allowList) == 0 {
|
||||
var allowListFile []string
|
||||
commandAllowListFile, err := os.Open(commandAllowListLocation)
|
||||
defer commandAllowListFile.Close()
|
||||
if err != nil {
|
||||
log.Println("[error] getAllowList error with COMMANDS_ALLOWLIST: " + commandAllowListLocation + " not found and will be ignored")
|
||||
} else {
|
||||
defer commandAllowListFile.Close()
|
||||
byteValue, err := ioutil.ReadAll(commandAllowListFile)
|
||||
if err != nil {
|
||||
log.Println("[error] getAllowList error while reading COMMANDS_ALLOWLIST: " + commandAllowListLocation + " it will be ignored")
|
||||
|
||||
Reference in New Issue
Block a user