Skip to content

Instantly share code, notes, and snippets.

@dhruvr
Last active October 2, 2019 17:24
Show Gist options
  • Save dhruvr/719695d1096392341969b1711287f27b to your computer and use it in GitHub Desktop.
Save dhruvr/719695d1096392341969b1711287f27b to your computer and use it in GitHub Desktop.
CallingClose.go
func main(){
fileName := "xyz.txt"
f, err := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE, 0755)
if err != nil {
if os.IsNotExist(err) {
log.Fatalf("Fatal, Problem while opening file %v for logging, err: %v \n", args.logFile, err)
}
}
//-----------------------------
//focus here we are calling the Close here
defer Close(f)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment