diff --git a/cmd/kratos/internal/upgrade/upgrade.go b/cmd/kratos/internal/upgrade/upgrade.go index 2b92690a5..9c110f8ce 100644 --- a/cmd/kratos/internal/upgrade/upgrade.go +++ b/cmd/kratos/internal/upgrade/upgrade.go @@ -21,6 +21,7 @@ func Run(cmd *cobra.Command, args []string) { err := base.GoGet( "github.com/go-kratos/kratos/cmd/kratos/v2", "github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2", + "github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2", "google.golang.org/protobuf/cmd/protoc-gen-go", "google.golang.org/grpc/cmd/protoc-gen-go-grpc", ) diff --git a/cmd/protoc-gen-go-errors/go.mod b/cmd/protoc-gen-go-errors/go.mod index b0f2b1d30..8469b6e0b 100644 --- a/cmd/protoc-gen-go-errors/go.mod +++ b/cmd/protoc-gen-go-errors/go.mod @@ -3,6 +3,6 @@ module github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 go 1.15 require ( - github.com/go-kratos/kratos/v2 v2.0.0-20210608032802-c551448bbd64 + github.com/go-kratos/kratos/v2 v2.0.0-20210608085308-7585257f9ea1 google.golang.org/protobuf v1.26.0 ) diff --git a/cmd/protoc-gen-go-errors/go.sum b/cmd/protoc-gen-go-errors/go.sum index 74e17b32b..075532fc0 100644 --- a/cmd/protoc-gen-go-errors/go.sum +++ b/cmd/protoc-gen-go-errors/go.sum @@ -12,6 +12,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/go-kratos/kratos/v2 v2.0.0-20210608032802-c551448bbd64 h1:+x/Zgv46tYhyhdWgoASZRWQpwuaEoHtNz0PMfwT9svM= github.com/go-kratos/kratos/v2 v2.0.0-20210608032802-c551448bbd64/go.mod h1:puDEhRv+dqKa4ZdlInEAbO8ibGxqNhAXFjGleIRh9V4= +github.com/go-kratos/kratos/v2 v2.0.0-20210608085308-7585257f9ea1 h1:t6O9azVp+Go2H1B5X9xEFgMj5jogpaL0obRz14ek+B0= +github.com/go-kratos/kratos/v2 v2.0.0-20210608085308-7585257f9ea1/go.mod h1:puDEhRv+dqKa4ZdlInEAbO8ibGxqNhAXFjGleIRh9V4= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= diff --git a/cmd/protoc-gen-go-errors/main.go b/cmd/protoc-gen-go-errors/main.go index e93ebae83..4c23d29d6 100644 --- a/cmd/protoc-gen-go-errors/main.go +++ b/cmd/protoc-gen-go-errors/main.go @@ -7,7 +7,7 @@ import ( "google.golang.org/protobuf/types/pluginpb" ) -const version = "v2.0.0-beta2" +const version = "v2.0.0-rc1" func main() { showVersion := flag.Bool("version", false, "print the version and exit") @@ -17,7 +17,6 @@ func main() { fmt.Printf("protoc-gen-go-errors %v\n", version) return } - //fmt.Println(os.Args, "123123") var flags flag.FlagSet protogen.Options{ ParamFunc: flags.Set, diff --git a/cmd/protoc-gen-go-errors/template.go b/cmd/protoc-gen-go-errors/template.go index 72be3a9f8..19c954712 100644 --- a/cmd/protoc-gen-go-errors/template.go +++ b/cmd/protoc-gen-go-errors/template.go @@ -10,10 +10,7 @@ var errorsTemplate = ` func Is{{.CamelValue}}(err error) bool { e := errors.FromError(err) - if e.Reason == {{.Name}}_{{.Value}}.String() && e.Code == {{.HttpCode}} { - return true - } - return false + return e.Reason == {{.Name}}_{{.Value}}.String() && e.Code == {{.HttpCode}} } func Error{{.CamelValue}}(format string, args ...interface{}) *errors.Error {