Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoc-gen-go-drpc: allow to generate service files to dedicated dir #25

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cmd/protoc-gen-go-drpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ import (
)

type config struct {
protolib string
json bool
protolib string
json bool
standalone bool
}

func main() {
var flags flag.FlagSet
var conf config
flags.StringVar(&conf.protolib, "protolib", "google.golang.org/protobuf", "which protobuf library to use for encoding")
flags.BoolVar(&conf.json, "json", true, "generate encoders with json support")
flags.BoolVar(&conf.standalone, "standalone", false, "generate code that work outside of generated messages")

protogen.Options{
ParamFunc: flags.Set,
Expand All @@ -40,7 +42,11 @@ func main() {
}

func generateFile(plugin *protogen.Plugin, file *protogen.File, conf config) {
gf := plugin.NewGeneratedFile(file.GeneratedFilenamePrefix+"_drpc.pb.go", file.GoImportPath)
path := file.GoImportPath
if conf.standalone {
path = "."
}
gf := plugin.NewGeneratedFile(file.GeneratedFilenamePrefix+"_drpc.pb.go", path)
d := &drpc{gf, file}

d.P("// Code generated by protoc-gen-go-drpc. DO NOT EDIT.")
Expand Down