log.Fatal は os.Exit() を呼び出すので、deferは if文の下で良さそう
file, err := os.Open('hoge.txt')
if err != nil {
log.Fatal(err)
}
defer file.Close()
Go to list of users who liked
More than 5 years have passed since last update.
log.Fatal は os.Exit() を呼び出すので、deferは if文の下で良さそう
file, err := os.Open('hoge.txt')
if err != nil {
log.Fatal(err)
}
defer file.Close()
Register as a new user and use Qiita more conveniently
Go to list of users who liked