Advertisement
cwchen

[Go] init function demo.

Sep 30th, 2017
837
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.33 KB | None | 0 0
  1. func init() {
  2.     if user == "" {
  3.         log.Fatal("$USER not set")
  4.     }
  5.     if home == "" {
  6.         home = "/home/" + user
  7.     }
  8.     if gopath == "" {
  9.         gopath = home + "/go"
  10.     }
  11.     // gopath may be overridden by --gopath flag on command line.
  12.     flag.StringVar(&gopath, "gopath", gopath, "override default GOPATH")
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement