This commit is contained in:
anqiansong
2022-03-09 19:26:35 +08:00
committed by GitHub
parent 63b7d292c1
commit 4624390e54
11 changed files with 335 additions and 131 deletions

View File

@@ -11,10 +11,10 @@ import (
// GoBin returns a path of GOBIN.
func GoBin() string {
def := build.Default
goroot := os.Getenv("GOROOT")
goroot := os.Getenv("GOPATH")
bin := filepath.Join(goroot, "bin")
if !pathx.FileExists(bin) {
gopath := os.Getenv("GOPATH")
gopath := os.Getenv("GOROOT")
bin = filepath.Join(gopath, "bin")
}
if !pathx.FileExists(bin) {

View File

@@ -23,8 +23,11 @@ func Install(cacheDir string) (string, error) {
}
func Exists() bool {
_, err := env.LookUpProtocGenGo()
return err == nil
ver, err := Version()
if err != nil {
return false
}
return len(ver) > 0
}
// Version is used to get the version of the protoc-gen-go plugin. For older versions, protoc-gen-go does not support