feat(cmd/upgrade): compatible with go get and go install (#1255)
* feat(cmd/upgrade): compatible with go get and go installpull/1257/head
parent
c7fcd388b5
commit
9808ceb7a8
@ -0,0 +1,24 @@ |
||||
//go:build go1.17
|
||||
// +build go1.17
|
||||
|
||||
package base |
||||
|
||||
import ( |
||||
"fmt" |
||||
"os" |
||||
"os/exec" |
||||
) |
||||
|
||||
// GoInstall go get path.
|
||||
func GoInstall(path ...string) error { |
||||
for _, p := range path { |
||||
fmt.Printf("go install %s@latest\n", p) |
||||
cmd := exec.Command("go", "install", fmt.Sprintf("%s@latest", p)) |
||||
cmd.Stdout = os.Stdout |
||||
cmd.Stderr = os.Stderr |
||||
if err := cmd.Run(); err != nil { |
||||
return err |
||||
} |
||||
} |
||||
return nil |
||||
} |
@ -0,0 +1,24 @@ |
||||
//go:build !go1.17
|
||||
// +build !go1.17
|
||||
|
||||
package base |
||||
|
||||
import ( |
||||
"fmt" |
||||
"os" |
||||
"os/exec" |
||||
) |
||||
|
||||
// GoInstall go get path.
|
||||
func GoInstall(path ...string) error { |
||||
for _, p := range path { |
||||
fmt.Printf("go get -u %s\n", p) |
||||
cmd := exec.Command("go", "get", "-u", p) |
||||
cmd.Stdout = os.Stdout |
||||
cmd.Stderr = os.Stderr |
||||
if err := cmd.Run(); err != nil { |
||||
return err |
||||
} |
||||
} |
||||
return nil |
||||
} |
Loading…
Reference in new issue