Open
Description
Given a proto definition
enum Foo {
BAR = 0;
BAZ = 1;
}
generates the following
type Foo int32
const (
Foo_BAR Foo = 0
Foo_BAZ Foo = 1
)
Protobuf enums already follow C++ scoping rules though so this seems unnecessary as you should be guaranteed of not having a collision within a single package.
protoc rejects the following already:
syntax = "proto3";
package testpkg;
option go_package = "testpkg";
enum Foo {
BAR = 0;
BAZ = 1;
}
enum Foo2 {
BAR = 1;
}
test.proto:31:5: "BAR" is already defined in "testpkg".
test.proto:31:5: Note that enum values use C++ scoping rules, meaning that enum values are siblings of their type, not children of it. Therefore, "BAR" must be unique within "testpkg", not just within "Foo2".
This may seem small but in practice we have found it to make code harder to read and follow with longer enums (both longer type name and longer enum values).
Unless I'm missing something that makes this required behavior it would be nice to have an option to turn this off.