Advertisement
cwchen

[Go] defer demo.

Sep 16th, 2017
881
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.15 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "log"
  5.     "os"
  6. )
  7.  
  8. func main() {
  9.     f, err := os.Open("file.txt")
  10.     if err != nil {
  11.         log.Fatal(err)
  12.     }
  13.     defer f.Close()
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement