Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CreateCmd = &cobra.Command{ Use: "create", Short: "create the proto code", Long: "create the proto code", Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 { fmt.Println("Enter proto files or directory") return } plugins := []string{ "protoc-gen-go", "protoc-gen-go-grpc", "protoc-gen-http", "protoc-gen-openapi", "protoc-gen-validate", "protoc-gen-errors", "wire", "statik", "yq", "protoc-go-inject-tag", } err := find(plugins...) if err != nil { cmd := exec.Command("slark", "install") cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err = cmd.Run(); err != nil { return } } else { cmd := exec.Command("protoc-gen-http", "--version") var out bytes.Buffer cmd.Stdout = &out cmd.Stderr = os.Stderr if err = cmd.Run(); err != nil { return } version := strings.TrimSpace(strings.Split(out.String(), " ")[1]) fmt.Printf("history version:%s\ncurrent version:%s\n", version, release) if strings.Compare(version, release) != 0 { cmd := exec.Command("slark", "install") cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err = cmd.Run(); err != nil { return } } } debug = len(args) >= 2 err = walk(strings.TrimSpace(args[0])) if err != nil { fmt.Println(err) } }, }
View Source
var InstallCmd = &cobra.Command{ Use: "install", Short: "install relative plugin", Long: "install relative plugin", Run: func(cmd *cobra.Command, args []string) { plugins := []string{ "google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0", "google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0", "github.com/envoyproxy/protoc-gen-validate@latest", "github.com/favadi/protoc-go-inject-tag@latest", "github.com/google/gnostic/cmd/protoc-gen-openapi@latest", "github.com/go-slark/slark/cmd/protoc-gen-http@latest", "github.com/go-slark/slark/cmd/protoc-gen-errors@latest", "github.com/google/wire/cmd/wire@latest", "github.com/rakyll/statik@latest", "github.com/mikefarah/yq/v4@latest", } for _, plugin := range plugins { fmt.Printf("go install %s\n", plugin) c := exec.Command("go", "install", plugin) c.Stdout = os.Stdout c.Stderr = os.Stderr err := c.Run() if err != nil { fmt.Printf("insatll %s fail, err:%+v\n", plugin, err) return } } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.