MCPcopy
hub / github.com/golang/protobuf / main

Function main

protoc-gen-go/main.go:36–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34)
35
36func main() {
37 var (
38 flags flag.FlagSet
39 plugins = flags.String("plugins", "", "list of plugins to enable (supported values: grpc)")
40 importPrefix = flags.String("import_prefix", "", "prefix to prepend to import paths")
41 )
42 importRewriteFunc := func(importPath protogen.GoImportPath) protogen.GoImportPath {
43 switch importPath {
44 case "context", "fmt", "math":
45 return importPath
46 }
47 if *importPrefix != "" {
48 return protogen.GoImportPath(*importPrefix) + importPath
49 }
50 return importPath
51 }
52 protogen.Options{
53 ParamFunc: flags.Set,
54 ImportRewriteFunc: importRewriteFunc,
55 }.Run(func(gen *protogen.Plugin) error {
56 grpc := false
57 for _, plugin := range strings.Split(*plugins, ",") {
58 switch plugin {
59 case "grpc":
60 grpc = true
61 case "":
62 default:
63 return fmt.Errorf("protoc-gen-go: unknown plugin %q", plugin)
64 }
65 }
66 for _, f := range gen.Files {
67 if !f.Generate {
68 continue
69 }
70 g := gengo.GenerateFile(gen, f)
71 if grpc {
72 gengogrpc.GenerateFileContent(gen, f, g)
73 }
74 }
75 gen.SupportedFeatures = gengo.SupportedFeatures
76 return nil
77 })
78}

Callers

nothing calls this directly

Calls 3

GenerateFileContentFunction · 0.92
GoImportPathMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected