grpc / grpc-go

The Go language implementation of gRPC. HTTP/2 based RPC

Home Page:https://grpc.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue creating a ENUM with "name" field

imaskm opened this issue · comments

Please see the FAQ in our main README.md before submitting your issue.

Hi, I am creating an ENUM called SortOn which has a field "name" ,

enum SortOn {
  created_at = 1;
  name = 2;
  size = 3;
  region = 4;
}

but the pb.go generated by protoc creates a constant:


const (
	
	SortOn_name      SortOn = 2
)

also a value map for the enum with the same name:

// Enum value maps for SortOn.
var (
	SortOn_name = map[int32]string{
		0: "id",
		1: "created_at",
		2: "name",
		3: "size",
		4: "region",
	}

which is a compilation error, How should I handle this? I need the field "name" in my enum.

For help, please file an issue in the protobuf repo instead. We own the code generator for services and methods but not data types (messages/enums/etc):

https://github.com/golang/protobuf

The only way to do this is using Uppercase for enum fields, which is also the best practice for proto.