try to fix this when working in a go.work env
This commit is contained in:
parent
21ab45b3f5
commit
c3d018df22
24
main.go
24
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
|
||||
}
|
||||
|
||||
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)
|
||||
cmd = []string{"go", "list", "-f", "'{{.Name}}'"}
|
||||
result = shell.RunQuiet(cmd)
|
||||
os.Unsetenv("GO111MODULE")
|
||||
}
|
||||
|
||||
packageName := strings.Join(result.Stdout, "\n")
|
||||
packageName = strings.TrimSpace(packageName)
|
||||
|
|
Loading…
Reference in New Issue