summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-15 20:52:57 -0600
committerJeff Carr <[email protected]>2024-12-15 20:52:57 -0600
commitc3d018df22d40ae93174b092f1ae823abd616eca (patch)
tree47e91935d635aef073077a319a7d9f257d9d19ad /main.go
parent21ab45b3f59a0d36fd121b2edf3808eb39330551 (diff)
try to fix this when working in a go.work envv0.0.28v0.0.27
Diffstat (limited to 'main.go')
-rw-r--r--main.go32
1 files changed, 26 insertions, 6 deletions
diff --git a/main.go b/main.go
index 52e2d31..9fa2c01 100644
--- a/main.go
+++ b/main.go
@@ -9,6 +9,7 @@ import (
"strings"
"github.com/alexflint/go-arg"
+ "github.com/go-cmd/cmd"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log"
@@ -70,12 +71,31 @@ func main() {
shell.RunQuiet([]string{"go", "mod", "edit", "-go=1.18"}) // TODO: make this a global
}
- // TODO: switch to using forgepb
- // switch to forgepb
- os.Setenv("GO111MODULE", "off") // keeps go list working if go version is back versioned for compatability
- cmd := []string{"go", "list", "-f", "'{{.Name}}'"}
- result := shell.RunQuiet(cmd)
- os.Unsetenv("GO111MODULE")
+ var result cmd.Status
+ var cmd []string
+ if forge.IsGoWork() {
+ cmd = []string{"go", "work", "use"}
+ result = shell.Run(cmd)
+ log.Info(strings.Join(result.Stdout, "\n"))
+ log.Info(strings.Join(result.Stderr, "\n"))
+ if !shell.Exists("go.mod") {
+ cmd = []string{"go", "mod", "init"}
+ result = shell.Run(cmd)
+ log.Info(strings.Join(result.Stdout, "\n"))
+ log.Info(strings.Join(result.Stderr, "\n"))
+ }
+ cmd = []string{"go", "list", "-f", "'{{.Name}}'"}
+ result = shell.Run(cmd)
+ log.Info(strings.Join(result.Stdout, "\n"))
+ log.Info(strings.Join(result.Stderr, "\n"))
+ } else {
+ // TODO: switch to using forgepb
+ // switch to forgepb
+ os.Setenv("GO111MODULE", "off") // keeps go list working if go version is back versioned for compatability
+ cmd = []string{"go", "list", "-f", "'{{.Name}}'"}
+ result = shell.RunQuiet(cmd)
+ os.Unsetenv("GO111MODULE")
+ }
packageName := strings.Join(result.Stdout, "\n")
packageName = strings.TrimSpace(packageName)