Created
May 28, 2014 10:12
-
-
Save ik5/a2ce33e11a03183e1206 to your computer and use it in GitHub Desktop.
defer in go
This file contains hidden or 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 open_file { | |
f, err := os.Open("/tmp/a_file") | |
if err != nil { | |
log.Fatal("Unable to open a_file") | |
} | |
defer f.Close() | |
// do something here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment