1package packr 2 3import ( 4 "go/build" 5 "os" 6 "strings" 7) 8 9// GoPath returns the current GOPATH env var 10// or if it's missing, the default. 11func GoPath() string { 12 go_path := strings.Split(os.Getenv("GOPATH"), string(os.PathListSeparator)) 13 if len(go_path) == 0 || go_path[0] == "" { 14 return build.Default.GOPATH 15 } 16 return go_path[0] 17} 18 19// GoBin returns the current GO_BIN env var 20// or if it's missing, a default of "go" 21func GoBin() string { 22 go_bin := os.Getenv("GO_BIN") 23 if go_bin == "" { 24 return "go" 25 } 26 return go_bin 27} 28