From 0875f088d397e419ca96ef239ebadbdad7d8a53f Mon Sep 17 00:00:00 2001 From: blackroot Date: Wed, 11 Jan 2023 17:22:30 +0800 Subject: [PATCH] update plugin --- xcmd/hack/proto/create.go | 19 +++++++------------ xcmd/hack/proto/install.go | 3 +-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/xcmd/hack/proto/create.go b/xcmd/hack/proto/create.go index 4f7ea19..294c20a 100644 --- a/xcmd/hack/proto/create.go +++ b/xcmd/hack/proto/create.go @@ -22,7 +22,7 @@ var CreateCmd = &cobra.Command{ return } - plugins := []string{"protoc-gen-go", "protoc-gen-go-grpc", "protoc-gen-gin", "protoc-gen-openapiv2", "protoc-gen-validate", "wire", "protoc-go-inject-tag"} + plugins := []string{"protoc-gen-go", "protoc-gen-go-grpc", "protoc-gen-gin", "protoc-gen-openapiv2", "protoc-gen-validate", "protoc-go-inject-tag"} err := find(plugins...) if err != nil { cmd := exec.Command("hack", "install") @@ -104,8 +104,6 @@ func create(path, dir string) error { return fd.Run() } -// inject-tag - func injectTag(dir string) error { cmd := exec.Command("bash", "-c", fmt.Sprintf("find %s -name *.pb.go -type f ! -name *_http.pb.go -type f ! -name *_grpc.pb.go", dir)) var stdOut, stdErr bytes.Buffer @@ -115,24 +113,23 @@ func injectTag(dir string) error { fmt.Println(cmd.String()) } err := cmd.Run() - outStr, errStr := stdOut.String(), stdErr.String() + outStr, _ := stdOut.String(), stdErr.String() if err != nil { - fmt.Println("out str:", outStr) - fmt.Println("err str:", errStr) - fmt.Println("find err:", err) + fmt.Printf("find file fail, err:%+v\n", err) return err } - fmt.Println("5555:", errStr) - fmt.Print("77777:", outStr) for _, file := range strings.Split(outStr, "\n") { if len(file) == 0 { continue } - fmt.Println("file:", file) + cmd = exec.Command("protoc-go-inject-tag", "-input", file) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr + if debug { + fmt.Println(cmd.String()) + } err = cmd.Run() if err != nil { return err @@ -140,5 +137,3 @@ func injectTag(dir string) error { } return nil } - -// wire diff --git a/xcmd/hack/proto/install.go b/xcmd/hack/proto/install.go index 2a6be39..69c65f3 100644 --- a/xcmd/hack/proto/install.go +++ b/xcmd/hack/proto/install.go @@ -18,8 +18,7 @@ var InstallCmd = &cobra.Command{ "google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest", "github.com/envoyproxy/protoc-gen-validate@latest", "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest", - "github.com/google/wire/cmd/wire@latest", - "github.com/favadi/protoc-go-inject-tag@latest", + "github.com/smallfish-root/common-pkg/xcmd/protoc-gen-gin@latest", } for _, plugin := range plugins { fmt.Printf("go install %s\n", plugin)