upgrade.go 679 B

12345678910111213141516171819202122232425
  1. package upgrade
  2. import (
  3. "fmt"
  4. "runtime"
  5. "github.com/spf13/cobra"
  6. "github.com/wuntsong-org/go-zero-plus/tools/goctlwt/rpc/execx"
  7. )
  8. // upgrade gets the latest goctl by
  9. // go install github.com/wuntsong-org/go-zero-plus/tools/goctlwt@latest
  10. func upgrade(_ *cobra.Command, _ []string) error {
  11. cmd := `GO111MODULE=on GOPROXY=https://goproxy.cn/,direct go install github.com/wuntsong-org/go-zero-plus/tools/goctlwt@latest`
  12. if runtime.GOOS == "windows" {
  13. cmd = `set GOPROXY=https://goproxy.cn,direct && go install github.com/wuntsong-org/go-zero-plus/tools/goctlwt@latest`
  14. }
  15. info, err := execx.Run(cmd, "")
  16. if err != nil {
  17. return err
  18. }
  19. fmt.Print(info)
  20. return nil
  21. }