use os.Getenv
This commit is contained in:
parent
3d2a16f4fb
commit
01916154d9
13
main.go
13
main.go
@ -16,15 +16,10 @@ func main() {
|
|||||||
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
|
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
|
||||||
binDirs := []string{}
|
binDirs := []string{}
|
||||||
srcDirs := []string{}
|
srcDirs := []string{}
|
||||||
for _, env := range os.Environ() {
|
|
||||||
if strings.HasPrefix(env, "GOPATH=") {
|
for _, path := range filepath.SplitList(os.Getenv("GOPATH")) {
|
||||||
i := strings.Index(env, "=")
|
binDirs = append(binDirs, filepath.Join(path, "bin"))
|
||||||
paths := filepath.SplitList(env[i+1:])
|
srcDirs = append(srcDirs, filepath.Join(path, "src"))
|
||||||
for _, path := range paths {
|
|
||||||
binDirs = append(binDirs, filepath.Join(path, "bin"))
|
|
||||||
srcDirs = append(srcDirs, filepath.Join(path, "src"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
files := []string{}
|
files := []string{}
|
||||||
|
Loading…
Reference in New Issue
Block a user