summaryrefslogtreecommitdiff
path: root/build.go
diff options
context:
space:
mode:
Diffstat (limited to 'build.go')
-rw-r--r--build.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/build.go b/build.go
index 8fee1be..cf1f518 100644
--- a/build.go
+++ b/build.go
@@ -19,6 +19,7 @@ import (
"strings"
"time"
+ "go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
@@ -36,10 +37,14 @@ func (f *Forge) doBuild(repo *gitpb.Repo, userFlags []string, goWhat string) err
log.Warn("forge.doBuild repo == nil")
return errors.New("forge.doBuild repo == nil")
}
- // always assume all sources have been downloaded
- // todo: detect when in ~/go/src vs go.work mode
- os.Setenv("GO111MODULE", "off")
- defer os.Unsetenv("GO111MODULE")
+ if f.IsGoWork() {
+ // when building using a go.work file, never use GO111MODULE=off
+ os.Unsetenv("GO111MODULE")
+ } else {
+ // when building from ~/go/src, always use GO111MODULE=off
+ os.Setenv("GO111MODULE", "off")
+ defer os.Unsetenv("GO111MODULE")
+ }
// get the version
version := repo.GetCurrentBranchVersion()
@@ -94,6 +99,12 @@ func (f *Forge) doBuild(repo *gitpb.Repo, userFlags []string, goWhat string) err
cmd = append(cmd, "-ldflags", "-X "+flag)
}
+ testenv := os.Getenv("GO111MODULE")
+ if testenv == "off" {
+ log.Info("GO111MODULE=off", "f.goWork =", f.IsGoWork(), "f.gosrc =", f.GetGoSrc())
+ } else {
+ log.Info("GO111MODULE=", testenv, "f.goWork =", f.IsGoWork(), "f.gosrc =", f.GetGoSrc())
+ }
log.Info("running:", cmd)
result := repo.RunRealtime(cmd)
if result.Exit == 0 {
@@ -107,7 +118,7 @@ func (f *Forge) doBuild(repo *gitpb.Repo, userFlags []string, goWhat string) err
log.Warn("go build failed", cmd)
pwd, _ := os.Getwd()
log.Warn("go build pwd", pwd)
- res2 := repo.RunRealtime(cmd)
+ res2 := shell.RunEcho(cmd)
if res2.Exit == 0 {
log.Info("again failed", res2.Exit)
log.Info("again failed cmd", strings.Join(cmd, "a"))