src-d / proteus

Generate .proto files from Go source code.
https://blog.sourced.tech/post/proteus/
MIT License
735 stars 70 forks source link

Avoid generating String() methods #65

Closed smola closed 7 years ago

smola commented 7 years ago

proteus generates a String() method for my enums, but I already have one (generated by stringer). So I would like to avoid generating this String() method.

I don't care if this is a command line flag enabling it globally or annotation-based opt-in per type. Both would work for me.

➜  sdk git:(expand-uast) ✗ proteus --pkg github.com/bblfsh/sdk/uast --pkg github.com/bblfsh/sdk/protocol -f $GOPATH/src/github.com/bblfsh/sdk/protos --verbose
WARN: ignoring type interface{Next() /home/smola/dev/go/src/github.com/bblfsh/sdk/uast.Path}
WARN: ignoring type interface{Step(); /home/smola/dev/go/src/github.com/bblfsh/sdk/uast.PathIter}
WARN: ignoring type interface{ToNode(src interface{}) (*/home/smola/dev/go/src/github.com/bblfsh/sdk/uast.Node, error)}
error scanning package "github.com/bblfsh/sdk/protocol": /home/smola/dev/go/src/github.com/bblfsh/sdk/protocol/protocol.go:4:2: could not import github.com/bblfsh/sdk/uast (/home/smola/dev/go/src/github.com/bblfsh/sdk/uast/role_string.go:11:15: method String already declared for Role)
erizocosmico commented 7 years ago

It's not proteus, probably it's generated by gogo/protobuf, which requires a PR there so this might take a while.

Serabe commented 7 years ago

We just need to add an option. This can be done by adding an option. I'll try to do it checking we have all the options we want already there.

Serabe commented 7 years ago

We need to detect the String() method. If it is detected, we can add (gogoproto.goproto_stringer)=false for the given message / enum.