- fix wrong GOBIN when GOPATH includes multi directories

- support custom run method to config path to binary to run
This commit is contained in:
ThinhNT 2018-03-22 10:49:53 +07:00
parent 3ad56dd80c
commit e3c540875a
2 changed files with 5 additions and 1 deletions

View File

@ -65,7 +65,8 @@ func init() {
if build.Default.GOPATH == "" {
log.Fatal("$GOPATH isn't set properly")
}
if err := os.Setenv("GOBIN", filepath.Join(build.Default.GOPATH, "bin")); err != nil {
path := filepath.SplitList(build.Default.GOPATH)
if err := os.Setenv("GOBIN", filepath.Join(path[len(path)-1], "bin")); err != nil {
log.Fatal(err)
}
}

View File

@ -582,6 +582,9 @@ func (p *Project) run(path string, stream chan Response, stop <-chan bool) (err
name = filepath.Base(dirPath)
}
path = filepath.Join(dirPath, name)
if p.Tools.Run.Method != "" {
path = p.Tools.Run.Method
}
if _, err := os.Stat(path); err == nil {
build = exec.Command(path, args...)
} else if _, err := os.Stat(path + RExtWin); err == nil {