MCPcopy
hub / github.com/grpc-ecosystem/grpc-gateway / main

Function main

protoc-gen-grpc-gateway/main.go:51–126  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49)
50
51func main() {
52 flag.Parse()
53
54 if *versionFlag {
55 if commit == "unknown" {
56 buildInfo, ok := debug.ReadBuildInfo()
57 if ok {
58 version = buildInfo.Main.Version
59 for _, setting := range buildInfo.Settings {
60 if setting.Key == "vcs.revision" {
61 commit = setting.Value
62 }
63 if setting.Key == "vcs.time" {
64 date = setting.Value
65 }
66 }
67 }
68 }
69 fmt.Printf("Version %v, commit %v, built at %v\n", version, commit, date)
70 os.Exit(0)
71 }
72
73 protogen.Options{
74 ParamFunc: flag.CommandLine.Set,
75 }.Run(func(gen *protogen.Plugin) error {
76 reg := descriptor.NewRegistry()
77
78 if err := applyFlags(reg); err != nil {
79 return err
80 }
81
82 codegenerator.SetSupportedFeaturesOnPluginGen(gen)
83
84 generator := gengateway.New(reg, *useRequestContext, *registerFuncSuffix, *allowPatchFeature, *standalone, *useOpaqueAPI)
85
86 if grpclog.V(1) {
87 grpclog.Infof("Parsing code generator request")
88 }
89
90 if err := reg.LoadFromPlugin(gen); err != nil {
91 return err
92 }
93
94 unboundHTTPRules := reg.UnboundExternalHTTPRules()
95 if len(unboundHTTPRules) != 0 {
96 return fmt.Errorf("HTTP rules without a matching selector: %s", strings.Join(unboundHTTPRules, ", "))
97 }
98
99 targets := make([]*descriptor.File, 0, len(gen.Request.FileToGenerate))
100 for _, target := range gen.Request.FileToGenerate {
101 f, err := reg.LookupFile(target)
102 if err != nil {
103 return err
104 }
105 targets = append(targets, f)
106 }
107
108 files, err := generator.Generate(targets)

Callers

nothing calls this directly

Calls 10

LoadFromPluginMethod · 0.95
LookupFileMethod · 0.95
NewRegistryFunction · 0.92
NewFunction · 0.92
applyFlagsFunction · 0.85
ParseMethod · 0.65
GenerateMethod · 0.65
GetNameMethod · 0.45

Tested by

no test coverage detected