diff options
| author | Jeff Carr <[email protected]> | 2024-12-15 20:52:57 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-15 20:52:57 -0600 |
| commit | c3d018df22d40ae93174b092f1ae823abd616eca (patch) | |
| tree | 47e91935d635aef073077a319a7d9f257d9d19ad /main.go | |
| parent | 21ab45b3f59a0d36fd121b2edf3808eb39330551 (diff) | |
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 32 |
1 files changed, 26 insertions, 6 deletions
@@ -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) |
