diff --git a/tools/goctl/Makefile.linux b/tools/goctl/Makefile.linux new file mode 100644 index 00000000..ecd6eb6d --- /dev/null +++ b/tools/goctl/Makefile.linux @@ -0,0 +1,4 @@ +version := $(shell /bin/date "+%Y-%m-%d %H:%M") + +build: + GOOS=linux go build -ldflags="-s -w" -ldflags="-X 'main.BuildTime=$(version)'" goctl.go && upx goctl diff --git a/tools/goctl/rpc/ctx/ctx.go b/tools/goctl/rpc/ctx/ctx.go index 4dd76d2c..4610a585 100644 --- a/tools/goctl/rpc/ctx/ctx.go +++ b/tools/goctl/rpc/ctx/ctx.go @@ -76,7 +76,7 @@ func MustCreateRpcContext(protoSrc, targetDir, serviceName string, idea bool) *R func MustCreateRpcContextFromCli(ctx *cli.Context) *RpcContext { os := runtime.GOOS switch os { - case "darwin", "windows": + case "darwin", "linux", "windows": default: logx.Must(fmt.Errorf("unexpected os: %s", os)) } diff --git a/tools/goctl/rpc/execx/execx.go b/tools/goctl/rpc/execx/execx.go index 9d385612..14108f09 100644 --- a/tools/goctl/rpc/execx/execx.go +++ b/tools/goctl/rpc/execx/execx.go @@ -12,13 +12,14 @@ func Run(arg string) (string, error) { goos := runtime.GOOS var cmd *exec.Cmd switch goos { - case "darwin": + case "darwin", "linux": cmd = exec.Command("sh", "-c", arg) case "windows": cmd = exec.Command("cmd.exe", "/c", arg) default: return "", fmt.Errorf("unexpected os: %v", goos) } + dtsout := new(bytes.Buffer) stderr := new(bytes.Buffer) cmd.Stdout = dtsout @@ -30,5 +31,6 @@ func Run(arg string) (string, error) { } return "", err } + return dtsout.String(), nil } diff --git a/tools/goctl/rpc/gen/gendir.go b/tools/goctl/rpc/gen/gendir.go index 307e3989..aa798e76 100644 --- a/tools/goctl/rpc/gen/gendir.go +++ b/tools/goctl/rpc/gen/gendir.go @@ -45,7 +45,7 @@ func (g *defaultRpcGenerator) mustGetPackage(dir string) string { switch os { case "windows": relativePath = filepath.ToSlash(relativePath) - case "darwin": + case "darwin", "linux": default: g.Ctx.Fatalln("unexpected os: %s", os) }