go run fixed
This commit is contained in:
parent
918afd5756
commit
339a06a4d3
|
@ -19,7 +19,6 @@ import (
|
||||||
func (p *Project) goRun(channel chan bool, runner chan bool, wr *sync.WaitGroup) error {
|
func (p *Project) goRun(channel chan bool, runner chan bool, wr *sync.WaitGroup) error {
|
||||||
var build *exec.Cmd
|
var build *exec.Cmd
|
||||||
var args []string
|
var args []string
|
||||||
var path = ""
|
|
||||||
isErrorText := func(string) bool {
|
isErrorText := func(string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -37,25 +36,23 @@ func (p *Project) goRun(channel chan bool, runner chan bool, wr *sync.WaitGroup)
|
||||||
arr := strings.Fields(arg)
|
arr := strings.Fields(arg)
|
||||||
args = append(args, arr...)
|
args = append(args, arr...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(filepath.Join(p.base, p.path)); err == nil {
|
if _, err := os.Stat(filepath.Join(p.base, p.path)); err == nil {
|
||||||
path = filepath.Join(p.base, p.path)
|
p.path = filepath.Join(p.base, p.path)
|
||||||
}
|
}
|
||||||
if _, err := os.Stat(filepath.Join(p.base, p.path+".exe")); err == nil {
|
if _, err := os.Stat(filepath.Join(p.base, p.path+".exe")); err == nil {
|
||||||
path = filepath.Join(p.base, p.path+".exe")
|
p.path = filepath.Join(p.base, p.path+".exe")
|
||||||
}
|
}
|
||||||
|
|
||||||
if path != "" {
|
if _, err := os.Stat(filepath.Join(getEnvPath("GOBIN"), filepath.Base(p.path))); err == nil {
|
||||||
build = exec.Command(path, args...)
|
build = exec.Command(filepath.Join(getEnvPath("GOBIN"), filepath.Base(p.path)), args...)
|
||||||
|
} else if _, err := os.Stat(filepath.Join(getEnvPath("GOBIN"), filepath.Base(p.path)) + ".exe"); err == nil {
|
||||||
|
build = exec.Command(filepath.Join(getEnvPath("GOBIN"), filepath.Base(p.path))+".exe", args...)
|
||||||
} else {
|
} else {
|
||||||
if _, err := os.Stat(filepath.Join(getEnvPath("GOBIN"), filepath.Base(p.path))); err == nil {
|
p.Buffer.StdLog = append(p.Buffer.StdLog, BufferOut{Time: time.Now(), Text: "Can't run a not compiled project"})
|
||||||
build = exec.Command(filepath.Join(getEnvPath("GOBIN"), filepath.Base(p.path)), args...)
|
p.Fatal(err, "Can't run a not compiled project", ":")
|
||||||
} else if _, err := os.Stat(filepath.Join(getEnvPath("GOBIN"), filepath.Base(p.path)) + ".exe"); err == nil {
|
|
||||||
build = exec.Command(filepath.Join(getEnvPath("GOBIN"), filepath.Base(p.path))+".exe", args...)
|
|
||||||
} else {
|
|
||||||
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", ":")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := build.Process.Kill(); err != nil {
|
if err := build.Process.Kill(); err != nil {
|
||||||
p.Buffer.StdLog = append(p.Buffer.StdLog, BufferOut{Time: time.Now(), Text: "Failed to stop: " + err.Error()})
|
p.Buffer.StdLog = append(p.Buffer.StdLog, BufferOut{Time: time.Now(), Text: "Failed to stop: " + err.Error()})
|
||||||
|
|
Loading…
Reference in New Issue