From 39a38885d4be50d70cc29d054097af40c303a6e8 Mon Sep 17 00:00:00 2001 From: anqiansong Date: Sat, 29 Oct 2022 22:17:05 +0800 Subject: [PATCH 1/2] Fix #2561 --- tools/goctl/rpc/cli/cli.go | 7 +++++-- tools/goctl/rpc/cmd.go | 9 +++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/goctl/rpc/cli/cli.go b/tools/goctl/rpc/cli/cli.go index d7c0fea53677..451e3a770cca 100644 --- a/tools/goctl/rpc/cli/cli.go +++ b/tools/goctl/rpc/cli/cli.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/spf13/cobra" + "github.com/zeromicro/go-zero/tools/goctl/rpc/generator" "github.com/zeromicro/go-zero/tools/goctl/util" "github.com/zeromicro/go-zero/tools/goctl/util/console" @@ -104,8 +105,10 @@ func RPCNew(_ *cobra.Command, args []string) error { } // RPCTemplate is the entry for generate rpc template -func RPCTemplate(_ *cobra.Command, _ []string) error { - console.Warning("deprecated: goctl rpc template -o is deprecated and will be removed in the future, use goctl rpc -o instead") +func RPCTemplate(new bool) error { + if !new { + console.Warning("deprecated: goctl rpc template -o is deprecated and will be removed in the future, use goctl rpc -o instead") + } protoFile := VarStringOutput home := VarStringHome remote := VarStringRemote diff --git a/tools/goctl/rpc/cmd.go b/tools/goctl/rpc/cmd.go index f948fa2f1001..61a986b6ac3d 100644 --- a/tools/goctl/rpc/cmd.go +++ b/tools/goctl/rpc/cmd.go @@ -2,6 +2,7 @@ package rpc import ( "github.com/spf13/cobra" + "github.com/zeromicro/go-zero/tools/goctl/rpc/cli" ) @@ -10,7 +11,9 @@ var ( Cmd = &cobra.Command{ Use: "rpc", Short: "Generate rpc code", - RunE: cli.RPCTemplate, + RunE: func(cmd *cobra.Command, args []string) error { + return cli.RPCTemplate(true) + }, } newCmd = &cobra.Command{ @@ -23,7 +26,9 @@ var ( templateCmd = &cobra.Command{ Use: "template", Short: "Generate proto template", - RunE: cli.RPCTemplate, + RunE: func(cmd *cobra.Command, args []string) error { + return cli.RPCTemplate(false) + }, } protocCmd = &cobra.Command{ From 45d89488369ad502c63cef650d2a3bfb55209b32 Mon Sep 17 00:00:00 2001 From: anqiansong Date: Sat, 29 Oct 2022 22:29:54 +0800 Subject: [PATCH 2/2] format code --- tools/goctl/rpc/cli/cli.go | 5 ++--- tools/goctl/rpc/cmd.go | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/goctl/rpc/cli/cli.go b/tools/goctl/rpc/cli/cli.go index 451e3a770cca..fc1288d36ecd 100644 --- a/tools/goctl/rpc/cli/cli.go +++ b/tools/goctl/rpc/cli/cli.go @@ -7,7 +7,6 @@ import ( "strings" "github.com/spf13/cobra" - "github.com/zeromicro/go-zero/tools/goctl/rpc/generator" "github.com/zeromicro/go-zero/tools/goctl/util" "github.com/zeromicro/go-zero/tools/goctl/util/console" @@ -105,8 +104,8 @@ func RPCNew(_ *cobra.Command, args []string) error { } // RPCTemplate is the entry for generate rpc template -func RPCTemplate(new bool) error { - if !new { +func RPCTemplate(latest bool) error { + if !latest { console.Warning("deprecated: goctl rpc template -o is deprecated and will be removed in the future, use goctl rpc -o instead") } protoFile := VarStringOutput diff --git a/tools/goctl/rpc/cmd.go b/tools/goctl/rpc/cmd.go index 61a986b6ac3d..6beae0deaba6 100644 --- a/tools/goctl/rpc/cmd.go +++ b/tools/goctl/rpc/cmd.go @@ -2,7 +2,6 @@ package rpc import ( "github.com/spf13/cobra" - "github.com/zeromicro/go-zero/tools/goctl/rpc/cli" )