Merge pull request #61 from Traum-Ferienwohnungen/fix_multi_GOPATH
Support multiple values in GOPATH/GOBIN
This commit is contained in:
commit
0e6c513b14
|
@ -47,10 +47,10 @@ func (p *Project) goRun(channel chan bool, runner chan bool, wr *sync.WaitGroup)
|
||||||
if path != "" {
|
if path != "" {
|
||||||
build = exec.Command(path, args...)
|
build = exec.Command(path, args...)
|
||||||
} else {
|
} else {
|
||||||
if _, err := os.Stat(filepath.Join(os.Getenv("GOBIN"), filepath.Base(p.path))); err == nil {
|
if _, err := os.Stat(filepath.Join(getEnvPath("GOBIN"), filepath.Base(p.path))); err == nil {
|
||||||
build = exec.Command(filepath.Join(os.Getenv("GOBIN"), filepath.Base(p.path)), args...)
|
build = exec.Command(filepath.Join(getEnvPath("GOBIN"), filepath.Base(p.path)), params...)
|
||||||
} else if _, err := os.Stat(filepath.Join(os.Getenv("GOBIN"), filepath.Base(p.path)) + ".exe"); err == nil {
|
} else if _, err := os.Stat(filepath.Join(getEnvPath("GOBIN"), filepath.Base(p.path)) + ".exe"); err == nil {
|
||||||
build = exec.Command(filepath.Join(os.Getenv("GOBIN"), filepath.Base(p.path))+".exe", args...)
|
build = exec.Command(filepath.Join(getEnvPath("GOBIN"), filepath.Base(p.path))+".exe", params...)
|
||||||
} else {
|
} else {
|
||||||
p.Buffer.StdLog = append(p.Buffer.StdLog, BufferOut{Time: time.Now(), Text: "Can't run a not compiled project"})
|
p.Buffer.StdLog = append(p.Buffer.StdLog, BufferOut{Time: time.Now(), Text: "Can't run a not compiled project"})
|
||||||
p.Fatal(err, "Can't run a not compiled project", ":")
|
p.Fatal(err, "Can't run a not compiled project", ":")
|
||||||
|
@ -132,7 +132,7 @@ func (p *Project) goBuild() (string, error) {
|
||||||
func (p *Project) goInstall() (string, error) {
|
func (p *Project) goInstall() (string, error) {
|
||||||
var out bytes.Buffer
|
var out bytes.Buffer
|
||||||
var stderr bytes.Buffer
|
var stderr bytes.Buffer
|
||||||
err := os.Setenv("GOBIN", filepath.Join(os.Getenv("GOPATH"), "bin"))
|
err := os.Setenv("GOBIN", filepath.Join(getEnvPath("GOPATH"), "bin"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package watcher
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tockins/realize/style"
|
"github.com/tockins/realize/style"
|
||||||
|
@ -46,3 +48,13 @@ func inArray(str string, list []string) bool {
|
||||||
func (w logWriter) Write(bytes []byte) (int, error) {
|
func (w logWriter) Write(bytes []byte) (int, error) {
|
||||||
return fmt.Print(style.Yellow.Regular("[") + time.Now().Format("15:04:05") + style.Yellow.Regular("]") + string(bytes))
|
return fmt.Print(style.Yellow.Regular("[") + time.Now().Format("15:04:05") + style.Yellow.Regular("]") + string(bytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getEnvPath returns the first path found in env or empty string
|
||||||
|
func getEnvPath(env string) string {
|
||||||
|
path := filepath.SplitList(os.Getenv(env))
|
||||||
|
if len(path) == 0 {
|
||||||
|
return ""
|
||||||
|
} else {
|
||||||
|
return path[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue