mirror of
https://github.com/issadarkthing/gomu.git
synced 2025-04-28 13:48:53 +08:00
move defer after err check
This commit is contained in:
parent
a6e0689cad
commit
db80ab25c7
2
utils.go
2
utils.go
@ -215,10 +215,10 @@ func contains(needle int, haystack []int) bool {
|
||||
|
||||
func appendFile(path string, content string) error {
|
||||
f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
defer f.Close()
|
||||
if err != nil {
|
||||
return tracerr.Wrap(err)
|
||||
}
|
||||
defer f.Close()
|
||||
if _, err := f.WriteString(content); err != nil {
|
||||
return tracerr.Wrap(err)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user