mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
build: Extract setGoPath
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3117
This commit is contained in:
parent
852759f904
commit
77e47066ed
22
build.go
22
build.go
@ -117,16 +117,8 @@ func main() {
|
|||||||
log.SetOutput(os.Stdout)
|
log.SetOutput(os.Stdout)
|
||||||
log.SetFlags(0)
|
log.SetFlags(0)
|
||||||
|
|
||||||
// If GOPATH isn't set, set it correctly with the assumption that we are
|
|
||||||
// in $GOPATH/src/github.com/syncthing/syncthing.
|
|
||||||
if os.Getenv("GOPATH") == "" {
|
if os.Getenv("GOPATH") == "" {
|
||||||
cwd, err := os.Getwd()
|
setGoPath()
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
gopath := filepath.Clean(filepath.Join(cwd, "../../../../"))
|
|
||||||
log.Println("GOPATH is", gopath)
|
|
||||||
os.Setenv("GOPATH", gopath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use Go 1.5+ vendoring.
|
// We use Go 1.5+ vendoring.
|
||||||
@ -241,6 +233,18 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setGoPath sets GOPATH correctly with the assumption that we are
|
||||||
|
// in $GOPATH/src/github.com/syncthing/syncthing.
|
||||||
|
func setGoPath() {
|
||||||
|
cwd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
gopath := filepath.Clean(filepath.Join(cwd, "../../../../"))
|
||||||
|
log.Println("GOPATH is", gopath)
|
||||||
|
os.Setenv("GOPATH", gopath)
|
||||||
|
}
|
||||||
|
|
||||||
func checkRequiredGoVersion() (float64, bool) {
|
func checkRequiredGoVersion() (float64, bool) {
|
||||||
re := regexp.MustCompile(`go(\d+\.\d+)`)
|
re := regexp.MustCompile(`go(\d+\.\d+)`)
|
||||||
ver := runtime.Version()
|
ver := runtime.Version()
|
||||||
|
Loading…
Reference in New Issue
Block a user