Closed smola closed 7 years ago
As a workaround, you can do Foo = 1 + iota
instead of using _ = iota
.
@erizocosmico :+1: thanks!
@smola on a second thought, we can't do anything to solve that on the proteus side. Protobuf enums must start at 0 (https://developers.google.com/protocol-buffers/docs/proto3#enum) If you want the enums to match you'll have to start at 0.
Talk to @Serabe tomorrow IRL.
@smola one thing you could do is naming the invalid value, instead of using _
:
type Role uint64
const (
Invalid Role = iota
Foo
Bar
...
)
It's done extensively in the stdlib, so I don't think is a completely bad solution (example: https://golang.org/src/go/ast/scope.go?s=3516:3532#L127).
The drawback of this would be that INVALID
would be generated in the proto as well.
If that is not an OK solution for you guys, we'd have to look into options for respecting the mapping, but we can't promise there will be a solution for this, since enum values must start with 0 no matter what.
Ping @smola
Ping @smola
looks good to me
It seems that if you define an enum using
_ = iota
, the values in Go will start at1
, while the generated proto will start at0
.I couldn't really verify this yet. This is where I'm seeing divergences: https://github.com/bblfsh/sdk/blob/master/uast/uast.go https://github.com/bblfsh/sdk/blob/master/uast/generated.proto (
Roles
enum)