mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 12:05:50 +00:00
* [Go] Make enums into real types, add String() This changes the generated code for enums: instead of type aliases, they're now distinct types, allowing for better type-checking. Some client code may have to be changed to add casts. Enum types now have a String() method, so they implement fmt.Stringer. An EnumValues map is now generated, in addition to the existing EnumNames map, to easily map strings to values. Generated enum files are now gofmt-clean. Fixes #5207 * use example.ColorGreen explicitly * use valid enum value in mutation test, add new test for "invalid" enum * add length check and comment
33 lines
673 B
Go
33 lines
673 B
Go
// Code generated by the FlatBuffers compiler. DO NOT EDIT.
|
|
|
|
package NamespaceB
|
|
|
|
import "strconv"
|
|
|
|
type EnumInNestedNS int8
|
|
|
|
const (
|
|
EnumInNestedNSA EnumInNestedNS = 0
|
|
EnumInNestedNSB EnumInNestedNS = 1
|
|
EnumInNestedNSC EnumInNestedNS = 2
|
|
)
|
|
|
|
var EnumNamesEnumInNestedNS = map[EnumInNestedNS]string{
|
|
EnumInNestedNSA: "A",
|
|
EnumInNestedNSB: "B",
|
|
EnumInNestedNSC: "C",
|
|
}
|
|
|
|
var EnumValuesEnumInNestedNS = map[string]EnumInNestedNS{
|
|
"A": EnumInNestedNSA,
|
|
"B": EnumInNestedNSB,
|
|
"C": EnumInNestedNSC,
|
|
}
|
|
|
|
func (v EnumInNestedNS) String() string {
|
|
if s, ok := EnumNamesEnumInNestedNS[v]; ok {
|
|
return s
|
|
}
|
|
return "EnumInNestedNS(" + strconv.FormatInt(int64(v), 10) + ")"
|
|
}
|