-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprotoc-gen-go-sqlmap.go
More file actions
52 lines (41 loc) · 898 Bytes
/
protoc-gen-go-sqlmap.go
File metadata and controls
52 lines (41 loc) · 898 Bytes
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
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/roderm/protoc-gen-go-sqlmap/generator/generators/plain"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/pluginpb"
)
/* use gogo: */
// func main() {
// req := command.Read()
// resp := command.GeneratePlugin(req, gogo.New(), ".sqlmap.go")
// command.Write(resp)
// }
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 := plain.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))
}