-
Notifications
You must be signed in to change notification settings - Fork 806
Open
Description
This is the official test case:
protobuf/test/enumcustomname/enumcustomname.proto
Lines 38 to 45 in b03c65e
| enum MyEnum { | |
| option (gogoproto.enum_customname) = "MyCustomEnum"; | |
| // The following field will take on the custom name and the prefix, joined | |
| // by an underscore. | |
| A = 0 [(gogoproto.enumvalue_customname) = "MyBetterNameA"]; | |
| B = 1; // Should be MyCustomEnum_B | |
| } |
protobuf/test/enumcustomname/enumcustomname.pb.go
Lines 31 to 47 in b03c65e
| const ( | |
| // The following field will take on the custom name and the prefix, joined | |
| // by an underscore. | |
| MyCustomEnum_MyBetterNameA MyCustomEnum = 0 | |
| MyCustomEnum_B MyCustomEnum = 1 | |
| ) | |
| var MyCustomEnum_name = map[int32]string{ | |
| 0: "A", | |
| 1: "B", | |
| } | |
| var MyCustomEnum_value = map[string]int32{ | |
| "A": 0, | |
| "B": 1, | |
| } | |
In the above example, line 43 in the "enumcustomname.proto" file uses the "enumvalue_customname" extension to customize the name of the enumeration value. In the 34th page of "enumcustomname.pb.go", the variable name is the name of a custom enumeration value. However, lines 39 and 44 have not been replaced with custom enumeration names.
But I think the generated code should be like this:
const (
// The following field will take on the custom name and the prefix, joined
// by an underscore.
MyCustomEnum_MyBetterNameA MyCustomEnum = 0
MyCustomEnum_B MyCustomEnum = 1
)
var MyCustomEnum_name = map[int32]string{
0: "MyBetterNameA",
1: "B",
}
var MyCustomEnum_value = map[string]int32{
"MyBetterNameA": 0,
"B": 1,
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels