Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "enum", Short: "枚举生成器", Long: `枚举生成器`, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 { return } matchedFiles := []string{} for _, v := range args { files, err := filepath.Glob(v) cobra.CheckErr(err) if strings.HasSuffix(v, ".go") { matchedFiles = append(matchedFiles, files...) } } if len(matchedFiles) == 0 { return } for _, path := range matchedFiles { code, err := enum.G.Generate(path) cobra.CheckErr(err) if len(code) == 0 { continue } var genFile = "" if strings.HasSuffix(path, ".pb.go") { genFile = strings.ReplaceAll(path, ".pb.go", "_enum.pb.go") } else { genFile = strings.ReplaceAll(path, ".go", "_enum.go") } err = os.WriteFile(genFile, code, 0644) cobra.CheckErr(err) } }, }
EnumCmd 枚举生成器
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.