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:
Christopher Crawford
2022-02-16 15:02:54 -05:00
committed by GitHub
parent 57e338f819
commit 06f4af11b6
6 changed files with 1140 additions and 19 deletions

View 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) + ")"
}