From 676cbb15a8c41974f9076f8f7d71c78004858939 Mon Sep 17 00:00:00 2001 From: vanex <917232558@qq.com> Date: Sat, 21 Sep 2019 00:11:56 +0800 Subject: [PATCH 1/2] fix gopath compatible with windows --- tool/kratos-protoc/protoc.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tool/kratos-protoc/protoc.go b/tool/kratos-protoc/protoc.go index 75e25a737..accd6c518 100644 --- a/tool/kratos-protoc/protoc.go +++ b/tool/kratos-protoc/protoc.go @@ -144,7 +144,15 @@ func latestKratos() (string, error) { } func gopath() (gp string) { - gopaths := strings.Split(os.Getenv("GOPATH"), ":") + var gopaths []string + + switch runtime.GOOS { + case "windows": + gopaths = strings.Split(os.Getenv("GOPATH"), ";") + default: + gopaths = strings.Split(os.Getenv("GOPATH"), ":") + } + if len(gopaths) == 1 && gopaths[0] != "" { return gopaths[0] } From 6108084a4af66498e267b79a44197f67e5933812 Mon Sep 17 00:00:00 2001 From: vanex <917232558@qq.com> Date: Sat, 21 Sep 2019 00:31:59 +0800 Subject: [PATCH 2/2] find other gopath need compatible with windows --- tool/kratos/tool.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tool/kratos/tool.go b/tool/kratos/tool.go index c42ce6828..3b410d4c9 100644 --- a/tool/kratos/tool.go +++ b/tool/kratos/tool.go @@ -186,7 +186,15 @@ func (t Tool) installed() bool { } func gopath() (gp string) { - gopaths := strings.Split(os.Getenv("GOPATH"), ":") + var gopaths []string + + switch runtime.GOOS { + case "windows": + gopaths = strings.Split(os.Getenv("GOPATH"), ";") + default: + gopaths = strings.Split(os.Getenv("GOPATH"), ":") + } + if len(gopaths) == 1 && gopaths[0] != "" { return gopaths[0] }