[golang] Add support for text parsing with json struct tags (#7353)

* [golang] Add support for text parsing with json struct tags

Add struct tags to Go native structs generated when object API is used.

This allows to use the same JSON file as for C++ text
parsing(i.e. snake_case vs CamelCase) and thus enabling text parsing
for Go(when using object API).

* [golang] Add test for text parsing

Added small test to check and demonstrate text parsing in Go.
Also, ran clang-format on cpp file changes.
This commit is contained in:
Andrei Burdulescu
2022-08-08 21:30:06 +03:00
committed by GitHub
parent ee2ced236d
commit c793621567
13 changed files with 151 additions and 120 deletions

View File

@@ -7,42 +7,42 @@ import (
)
type ScalarStuffT struct {
JustI8 int8
MaybeI8 *int8
DefaultI8 int8
JustU8 byte
MaybeU8 *byte
DefaultU8 byte
JustI16 int16
MaybeI16 *int16
DefaultI16 int16
JustU16 uint16
MaybeU16 *uint16
DefaultU16 uint16
JustI32 int32
MaybeI32 *int32
DefaultI32 int32
JustU32 uint32
MaybeU32 *uint32
DefaultU32 uint32
JustI64 int64
MaybeI64 *int64
DefaultI64 int64
JustU64 uint64
MaybeU64 *uint64
DefaultU64 uint64
JustF32 float32
MaybeF32 *float32
DefaultF32 float32
JustF64 float64
MaybeF64 *float64
DefaultF64 float64
JustBool bool
MaybeBool *bool
DefaultBool bool
JustEnum OptionalByte
MaybeEnum *OptionalByte
DefaultEnum OptionalByte
JustI8 int8 `json:"just_i8"`
MaybeI8 *int8 `json:"maybe_i8"`
DefaultI8 int8 `json:"default_i8"`
JustU8 byte `json:"just_u8"`
MaybeU8 *byte `json:"maybe_u8"`
DefaultU8 byte `json:"default_u8"`
JustI16 int16 `json:"just_i16"`
MaybeI16 *int16 `json:"maybe_i16"`
DefaultI16 int16 `json:"default_i16"`
JustU16 uint16 `json:"just_u16"`
MaybeU16 *uint16 `json:"maybe_u16"`
DefaultU16 uint16 `json:"default_u16"`
JustI32 int32 `json:"just_i32"`
MaybeI32 *int32 `json:"maybe_i32"`
DefaultI32 int32 `json:"default_i32"`
JustU32 uint32 `json:"just_u32"`
MaybeU32 *uint32 `json:"maybe_u32"`
DefaultU32 uint32 `json:"default_u32"`
JustI64 int64 `json:"just_i64"`
MaybeI64 *int64 `json:"maybe_i64"`
DefaultI64 int64 `json:"default_i64"`
JustU64 uint64 `json:"just_u64"`
MaybeU64 *uint64 `json:"maybe_u64"`
DefaultU64 uint64 `json:"default_u64"`
JustF32 float32 `json:"just_f32"`
MaybeF32 *float32 `json:"maybe_f32"`
DefaultF32 float32 `json:"default_f32"`
JustF64 float64 `json:"just_f64"`
MaybeF64 *float64 `json:"maybe_f64"`
DefaultF64 float64 `json:"default_f64"`
JustBool bool `json:"just_bool"`
MaybeBool *bool `json:"maybe_bool"`
DefaultBool bool `json:"default_bool"`
JustEnum OptionalByte `json:"just_enum"`
MaybeEnum *OptionalByte `json:"maybe_enum"`
DefaultEnum OptionalByte `json:"default_enum"`
}
func (t *ScalarStuffT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {