forked from infobloxopen/protoc-gen-gorm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (35 loc) · 724 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
37
38
39
40
41
42
43
44
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/infobloxopen/protoc-gen-gorm/plugin"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/pluginpb"
)
func main() {
input, err := ioutil.ReadAll(os.Stdin)
if err != nil {
panic(err)
}
var request pluginpb.CodeGeneratorRequest
err = proto.Unmarshal(input, &request)
if err != nil {
panic(err)
}
opts := protogen.Options{}
builder, err := plugin.New(opts, &request)
if err != nil {
panic(err)
}
response, err := builder.Generate()
if err != nil {
panic(err)
}
out, err := proto.Marshal(response)
if err != nil {
panic(err)
}
fmt.Fprint(os.Stdout, string(out))
}