Last active
October 2, 2019 17:24
-
-
Save dhruvr/719695d1096392341969b1711287f27b to your computer and use it in GitHub Desktop.
CallingClose.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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