rpc generation support windows (#28)
* add execute files * add protoc-osx * add rpc generation * add rpc generation * add: rpc template generation * update usage * fixed env prepare for project in go path * optimize gomod cache * add README.md * format error * reactor templatex.go * remove waste code * update project.go & README.md * update project.go & README.md * rpc generation supports windows
This commit is contained in:
@@ -2,6 +2,7 @@ package gen
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/tal-tech/go-zero/tools/goctl/util"
|
||||
@@ -41,5 +42,13 @@ func (g *defaultRpcGenerator) mustGetPackage(dir string) string {
|
||||
target := g.dirM[dir]
|
||||
projectPath := g.Ctx.ProjectPath
|
||||
relativePath := strings.TrimPrefix(target, projectPath)
|
||||
os := runtime.GOOS
|
||||
switch os {
|
||||
case "windows":
|
||||
relativePath = filepath.ToSlash(relativePath)
|
||||
case "darwin":
|
||||
default:
|
||||
g.Ctx.Fatalln("unexpected os: %s", os)
|
||||
}
|
||||
return g.Ctx.Module + relativePath
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user