From 7e0b0ab0b118fdbe6cc38b4795bfa7aecd091d19 Mon Sep 17 00:00:00 2001 From: anqiansong Date: Fri, 1 Apr 2022 22:19:33 +0800 Subject: [PATCH] Fix zrpc code generation error with --remote (#1739) Co-authored-by: anqiansong --- tools/goctl/rpc/cli/zrpc.go | 7 ++++++- tools/goctl/rpc/cli/zrpc_test.go | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/goctl/rpc/cli/zrpc.go b/tools/goctl/rpc/cli/zrpc.go index fa84d8ea..2550f66c 100644 --- a/tools/goctl/rpc/cli/zrpc.go +++ b/tools/goctl/rpc/cli/zrpc.go @@ -118,13 +118,18 @@ func removeGoctlFlag(args []string) []string { for step < len(args) { arg := args[step] switch { - case arg == "--style", arg == "--home", arg == "--zrpc_out", arg == "--verbose", arg == "-v": + case arg == "--style", arg == "--home", + arg == "--zrpc_out", arg == "--verbose", + arg == "-v", arg == "--remote", + arg == "--branch": step += 2 continue case strings.HasPrefix(arg, "--style="), strings.HasPrefix(arg, "--home="), strings.HasPrefix(arg, "--verbose="), strings.HasPrefix(arg, "-v="), + strings.HasPrefix(arg, "--remote="), + strings.HasPrefix(arg, "--branch="), strings.HasPrefix(arg, "--zrpc_out="): step += 1 continue diff --git a/tools/goctl/rpc/cli/zrpc_test.go b/tools/goctl/rpc/cli/zrpc_test.go index 051556ad..d841115e 100644 --- a/tools/goctl/rpc/cli/zrpc_test.go +++ b/tools/goctl/rpc/cli/zrpc_test.go @@ -83,6 +83,14 @@ func Test_RemoveGoctlFlag(t *testing.T) { source: strings.Fields(`protoc --go_opt=. --go-grpc_out=. --zrpc_out=. foo.proto`), expected: "protoc --go_opt=. --go-grpc_out=. foo.proto", }, + { + source: strings.Fields(`protoc --go_opt=. --go-grpc_out=. --zrpc_out=. --remote=foo --branch=bar foo.proto`), + expected: "protoc --go_opt=. --go-grpc_out=. foo.proto", + }, + { + source: strings.Fields(`protoc --go_opt=. --go-grpc_out=. --zrpc_out=. --remote foo --branch bar foo.proto`), + expected: "protoc --go_opt=. --go-grpc_out=. foo.proto", + }, } for _, e := range testData { cmd := strings.Join(removeGoctlFlag(e.source), " ")