mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-30 23:41:38 +00:00
Go optional scalars (#7104)
* [go] always write required types * support optional scalars in go * generate optional_scalars and monster_test * restore original behavior for non-optional scalars * add tests
This commit is contained in:
committed by
GitHub
parent
57e338f819
commit
06f4af11b6
32
tests/optional_scalars/OptionalByte.go
Normal file
32
tests/optional_scalars/OptionalByte.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Code generated by the FlatBuffers compiler. DO NOT EDIT.
|
||||
|
||||
package optional_scalars
|
||||
|
||||
import "strconv"
|
||||
|
||||
type OptionalByte int8
|
||||
|
||||
const (
|
||||
OptionalByteNone OptionalByte = 0
|
||||
OptionalByteOne OptionalByte = 1
|
||||
OptionalByteTwo OptionalByte = 2
|
||||
)
|
||||
|
||||
var EnumNamesOptionalByte = map[OptionalByte]string{
|
||||
OptionalByteNone: "None",
|
||||
OptionalByteOne: "One",
|
||||
OptionalByteTwo: "Two",
|
||||
}
|
||||
|
||||
var EnumValuesOptionalByte = map[string]OptionalByte{
|
||||
"None": OptionalByteNone,
|
||||
"One": OptionalByteOne,
|
||||
"Two": OptionalByteTwo,
|
||||
}
|
||||
|
||||
func (v OptionalByte) String() string {
|
||||
if s, ok := EnumNamesOptionalByte[v]; ok {
|
||||
return s
|
||||
}
|
||||
return "OptionalByte(" + strconv.FormatInt(int64(v), 10) + ")"
|
||||
}
|
||||
Reference in New Issue
Block a user