build: Handle split GOPATH

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4447
This commit is contained in:
Simon Frei 2017-10-21 17:37:06 +00:00 committed by Jakob Borg
parent 20fac4bb80
commit 46becc5338

View File

@ -218,11 +218,18 @@ func main() {
os.Setenv("GOPATH", gopath) os.Setenv("GOPATH", gopath)
log.Println("GOPATH is", gopath) log.Println("GOPATH is", gopath)
} else { } else {
gopath, _ = filepath.EvalSymlinks(gopath) inside := false
wd, _ := os.Getwd() wd, _ := os.Getwd()
wd, _ = filepath.EvalSymlinks(wd) wd, _ = filepath.EvalSymlinks(wd)
if filepath.Join(gopath, "src/github.com/syncthing/syncthing") != wd { for _, p := range filepath.SplitList(gopath) {
fmt.Println("You are running this outside of GOPATH/src/github.com/syncthing/syncthing, this might cause failure!") p, _ = filepath.EvalSymlinks(p)
if filepath.Join(p, "src/github.com/syncthing/syncthing") == wd {
inside = true
break
}
}
if !inside {
fmt.Println("You seem to have GOPATH set but the Syncthing source not placed correctly within it, which may cause problems.")
} }
} }