MCPcopy Index your code
hub / github.com/maruel/panicparse / getGOPATHs

Function getGOPATHs

stack/context.go:1117–1152  ·  view source on GitHub ↗

getGOPATHs returns parsed GOPATH or its default, using "/" as path separator.

()

Source from the content-addressed store, hash-verified

1115
1116// getGOPATHs returns parsed GOPATH or its default, using "/" as path separator.
1117func getGOPATHs() []string {
1118 var out []string
1119 if gp := os.Getenv("GOPATH"); gp != "" {
1120 for _, v := range filepath.SplitList(gp) {
1121 // Disallow non-absolute paths?
1122 if v != "" {
1123 if runtime.GOOS == "windows" {
1124 v = strings.Replace(v, pathSeparator, "/", -1)
1125 }
1126 // Trim trailing "/".
1127 if l := len(v); v[l-1] == '/' {
1128 v = v[:l-1]
1129 }
1130 out = append(out, v)
1131 }
1132 }
1133 }
1134 if len(out) == 0 {
1135 homeDir := ""
1136 u, err := user.Current()
1137 if err != nil {
1138 homeDir = os.Getenv("HOME")
1139 if homeDir == "" {
1140 panic(fmt.Sprintf("Could not get current user or $HOME: %s\n", err.Error()))
1141 }
1142 } else {
1143 homeDir = u.HomeDir
1144 }
1145 p := homeDir + "/go"
1146 if runtime.GOOS == "windows" {
1147 p = strings.Replace(p, pathSeparator, "/", -1)
1148 }
1149 out = []string{p}
1150 }
1151 return out
1152}
1153
1154// atou is a fast Atoi() function.
1155//

Callers 3

TestGetGOPATHsFunction · 0.85
initFunction · 0.85
DefaultOptsFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestGetGOPATHsFunction · 0.68
initFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…