-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
36 lines (27 loc) · 771 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"flag"
"github.com/x-lambda/protoc-gen-gin/generator"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/types/pluginpb"
)
func main() {
var flags flag.FlagSet
var paramErrCode string
var errData bool
flags.StringVar(¶mErrCode, "code", "400", "the code of response data when param parse error")
flags.BoolVar(&errData, "err_data", false, "whether to return data when error occurs")
options := protogen.Options{
ParamFunc: flags.Set,
}
options.Run(func(gen *protogen.Plugin) error {
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
for _, f := range gen.Files {
if !f.Generate {
continue
}
generator.GenerateFile(gen, f)
}
return nil
})
}