mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-09 22:56:27 +00:00
Go: make generated code more compliant to "go fmt" (#7907)
Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
@@ -12,7 +12,9 @@ type AbilityT struct {
|
||||
}
|
||||
|
||||
func (t *AbilityT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
if t == nil {
|
||||
return 0
|
||||
}
|
||||
return CreateAbility(builder, t.Id, t.Distance)
|
||||
}
|
||||
func (rcv *Ability) UnPackTo(t *AbilityT) {
|
||||
@@ -21,7 +23,9 @@ func (rcv *Ability) UnPackTo(t *AbilityT) {
|
||||
}
|
||||
|
||||
func (rcv *Ability) UnPack() *AbilityT {
|
||||
if rcv == nil { return nil }
|
||||
if rcv == nil {
|
||||
return nil
|
||||
}
|
||||
t := &AbilityT{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
package Example
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
"strconv"
|
||||
|
||||
MyGame__Example2 "MyGame/Example2"
|
||||
)
|
||||
@@ -64,15 +64,15 @@ func (rcv Any) UnPack(table flatbuffers.Table) *AnyT {
|
||||
case AnyMonster:
|
||||
var x Monster
|
||||
x.Init(table.Bytes, table.Pos)
|
||||
return &AnyT{ Type: AnyMonster, Value: x.UnPack() }
|
||||
return &AnyT{Type: AnyMonster, Value: x.UnPack()}
|
||||
case AnyTestSimpleTableWithEnum:
|
||||
var x TestSimpleTableWithEnum
|
||||
x.Init(table.Bytes, table.Pos)
|
||||
return &AnyT{ Type: AnyTestSimpleTableWithEnum, Value: x.UnPack() }
|
||||
return &AnyT{Type: AnyTestSimpleTableWithEnum, Value: x.UnPack()}
|
||||
case AnyMyGame_Example2_Monster:
|
||||
var x MyGame__Example2.Monster
|
||||
x.Init(table.Bytes, table.Pos)
|
||||
return &AnyT{ Type: AnyMyGame_Example2_Monster, Value: x.UnPack() }
|
||||
return &AnyT{Type: AnyMyGame_Example2_Monster, Value: x.UnPack()}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
package Example
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type AnyAmbiguousAliases byte
|
||||
@@ -62,15 +62,15 @@ func (rcv AnyAmbiguousAliases) UnPack(table flatbuffers.Table) *AnyAmbiguousAlia
|
||||
case AnyAmbiguousAliasesM1:
|
||||
var x Monster
|
||||
x.Init(table.Bytes, table.Pos)
|
||||
return &AnyAmbiguousAliasesT{ Type: AnyAmbiguousAliasesM1, Value: x.UnPack() }
|
||||
return &AnyAmbiguousAliasesT{Type: AnyAmbiguousAliasesM1, Value: x.UnPack()}
|
||||
case AnyAmbiguousAliasesM2:
|
||||
var x Monster
|
||||
x.Init(table.Bytes, table.Pos)
|
||||
return &AnyAmbiguousAliasesT{ Type: AnyAmbiguousAliasesM2, Value: x.UnPack() }
|
||||
return &AnyAmbiguousAliasesT{Type: AnyAmbiguousAliasesM2, Value: x.UnPack()}
|
||||
case AnyAmbiguousAliasesM3:
|
||||
var x Monster
|
||||
x.Init(table.Bytes, table.Pos)
|
||||
return &AnyAmbiguousAliasesT{ Type: AnyAmbiguousAliasesM3, Value: x.UnPack() }
|
||||
return &AnyAmbiguousAliasesT{Type: AnyAmbiguousAliasesM3, Value: x.UnPack()}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
package Example
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
"strconv"
|
||||
|
||||
MyGame__Example2 "MyGame/Example2"
|
||||
)
|
||||
@@ -64,15 +64,15 @@ func (rcv AnyUniqueAliases) UnPack(table flatbuffers.Table) *AnyUniqueAliasesT {
|
||||
case AnyUniqueAliasesM:
|
||||
var x Monster
|
||||
x.Init(table.Bytes, table.Pos)
|
||||
return &AnyUniqueAliasesT{ Type: AnyUniqueAliasesM, Value: x.UnPack() }
|
||||
return &AnyUniqueAliasesT{Type: AnyUniqueAliasesM, Value: x.UnPack()}
|
||||
case AnyUniqueAliasesTS:
|
||||
var x TestSimpleTableWithEnum
|
||||
x.Init(table.Bytes, table.Pos)
|
||||
return &AnyUniqueAliasesT{ Type: AnyUniqueAliasesTS, Value: x.UnPack() }
|
||||
return &AnyUniqueAliasesT{Type: AnyUniqueAliasesTS, Value: x.UnPack()}
|
||||
case AnyUniqueAliasesM2:
|
||||
var x MyGame__Example2.Monster
|
||||
x.Init(table.Bytes, table.Pos)
|
||||
return &AnyUniqueAliasesT{ Type: AnyUniqueAliasesM2, Value: x.UnPack() }
|
||||
return &AnyUniqueAliasesT{Type: AnyUniqueAliasesM2, Value: x.UnPack()}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ package Example
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"math"
|
||||
flatbuffers "github.com/google/flatbuffers/go"
|
||||
"math"
|
||||
|
||||
MyGame "MyGame"
|
||||
)
|
||||
@@ -73,7 +73,9 @@ type MonsterT struct {
|
||||
}
|
||||
|
||||
func (t *MonsterT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
if t == nil {
|
||||
return 0
|
||||
}
|
||||
nameOffset := flatbuffers.UOffsetT(0)
|
||||
if t.Name != "" {
|
||||
nameOffset = builder.CreateString(t.Name)
|
||||
@@ -83,7 +85,7 @@ func (t *MonsterT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
inventoryOffset = builder.CreateByteString(t.Inventory)
|
||||
}
|
||||
testOffset := t.Test.Pack(builder)
|
||||
|
||||
|
||||
test4Offset := flatbuffers.UOffsetT(0)
|
||||
if t.Test4 != nil {
|
||||
test4Length := len(t.Test4)
|
||||
@@ -242,9 +244,9 @@ func (t *MonsterT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
vectorOfNonOwningReferencesOffset = builder.EndVector(vectorOfNonOwningReferencesLength)
|
||||
}
|
||||
anyUniqueOffset := t.AnyUnique.Pack(builder)
|
||||
|
||||
|
||||
anyAmbiguousOffset := t.AnyAmbiguous.Pack(builder)
|
||||
|
||||
|
||||
vectorOfEnumsOffset := flatbuffers.UOffsetT(0)
|
||||
if t.VectorOfEnums != nil {
|
||||
vectorOfEnumsLength := len(t.VectorOfEnums)
|
||||
@@ -493,7 +495,9 @@ func (rcv *Monster) UnPackTo(t *MonsterT) {
|
||||
}
|
||||
|
||||
func (rcv *Monster) UnPack() *MonsterT {
|
||||
if rcv == nil { return nil }
|
||||
if rcv == nil {
|
||||
return nil
|
||||
}
|
||||
t := &MonsterT{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
@@ -594,18 +598,18 @@ func (rcv *Monster) Name() []byte {
|
||||
func MonsterKeyCompare(o1, o2 flatbuffers.UOffsetT, buf []byte) bool {
|
||||
obj1 := &Monster{}
|
||||
obj2 := &Monster{}
|
||||
obj1.Init(buf, flatbuffers.UOffsetT(len(buf)) - o1)
|
||||
obj2.Init(buf, flatbuffers.UOffsetT(len(buf)) - o2)
|
||||
obj1.Init(buf, flatbuffers.UOffsetT(len(buf))-o1)
|
||||
obj2.Init(buf, flatbuffers.UOffsetT(len(buf))-o2)
|
||||
return string(obj1.Name()) < string(obj2.Name())
|
||||
}
|
||||
|
||||
func (rcv *Monster) LookupByKey(key string, vectorLocation flatbuffers.UOffsetT, buf []byte) bool {
|
||||
span := flatbuffers.GetUOffsetT(buf[vectorLocation - 4:])
|
||||
span := flatbuffers.GetUOffsetT(buf[vectorLocation-4:])
|
||||
start := flatbuffers.UOffsetT(0)
|
||||
bKey := []byte(key)
|
||||
for span != 0 {
|
||||
middle := span / 2
|
||||
tableOffset := flatbuffers.GetIndirectOffset(buf, vectorLocation+ 4 * (start + middle))
|
||||
tableOffset := flatbuffers.GetIndirectOffset(buf, vectorLocation+4*(start+middle))
|
||||
obj := &Monster{}
|
||||
obj.Init(buf, tableOffset)
|
||||
comp := bytes.Compare(obj.Name(), bKey)
|
||||
@@ -740,7 +744,7 @@ func (rcv *Monster) Testarrayoftables(obj *Monster, j int) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (rcv *Monster) TestarrayoftablesByKey(obj *Monster, key string) bool{
|
||||
func (rcv *Monster) TestarrayoftablesByKey(obj *Monster, key string) bool {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(26))
|
||||
if o != 0 {
|
||||
x := rcv._tab.Vector(o)
|
||||
@@ -1155,7 +1159,7 @@ func (rcv *Monster) VectorOfReferrables(obj *Referrable, j int) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (rcv *Monster) VectorOfReferrablesByKey(obj *Referrable, key uint64) bool{
|
||||
func (rcv *Monster) VectorOfReferrablesByKey(obj *Referrable, key uint64) bool {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(74))
|
||||
if o != 0 {
|
||||
x := rcv._tab.Vector(o)
|
||||
@@ -1222,7 +1226,7 @@ func (rcv *Monster) VectorOfStrongReferrables(obj *Referrable, j int) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (rcv *Monster) VectorOfStrongReferrablesByKey(obj *Referrable, key uint64) bool{
|
||||
func (rcv *Monster) VectorOfStrongReferrablesByKey(obj *Referrable, key uint64) bool {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(80))
|
||||
if o != 0 {
|
||||
x := rcv._tab.Vector(o)
|
||||
@@ -1449,7 +1453,7 @@ func (rcv *Monster) ScalarKeySortedTables(obj *Stat, j int) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (rcv *Monster) ScalarKeySortedTablesByKey(obj *Stat, key uint16) bool{
|
||||
func (rcv *Monster) ScalarKeySortedTablesByKey(obj *Stat, key uint16) bool {
|
||||
o := flatbuffers.UOffsetT(rcv._tab.Offset(104))
|
||||
if o != 0 {
|
||||
x := rcv._tab.Vector(o)
|
||||
|
||||
@@ -11,7 +11,9 @@ type ReferrableT struct {
|
||||
}
|
||||
|
||||
func (t *ReferrableT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
if t == nil {
|
||||
return 0
|
||||
}
|
||||
ReferrableStart(builder)
|
||||
ReferrableAddId(builder, t.Id)
|
||||
return ReferrableEnd(builder)
|
||||
@@ -22,7 +24,9 @@ func (rcv *Referrable) UnPackTo(t *ReferrableT) {
|
||||
}
|
||||
|
||||
func (rcv *Referrable) UnPack() *ReferrableT {
|
||||
if rcv == nil { return nil }
|
||||
if rcv == nil {
|
||||
return nil
|
||||
}
|
||||
t := &ReferrableT{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
@@ -78,17 +82,17 @@ func (rcv *Referrable) MutateId(n uint64) bool {
|
||||
func ReferrableKeyCompare(o1, o2 flatbuffers.UOffsetT, buf []byte) bool {
|
||||
obj1 := &Referrable{}
|
||||
obj2 := &Referrable{}
|
||||
obj1.Init(buf, flatbuffers.UOffsetT(len(buf)) - o1)
|
||||
obj2.Init(buf, flatbuffers.UOffsetT(len(buf)) - o2)
|
||||
obj1.Init(buf, flatbuffers.UOffsetT(len(buf))-o1)
|
||||
obj2.Init(buf, flatbuffers.UOffsetT(len(buf))-o2)
|
||||
return obj1.Id() < obj2.Id()
|
||||
}
|
||||
|
||||
func (rcv *Referrable) LookupByKey(key uint64, vectorLocation flatbuffers.UOffsetT, buf []byte) bool {
|
||||
span := flatbuffers.GetUOffsetT(buf[vectorLocation - 4:])
|
||||
span := flatbuffers.GetUOffsetT(buf[vectorLocation-4:])
|
||||
start := flatbuffers.UOffsetT(0)
|
||||
for span != 0 {
|
||||
middle := span / 2
|
||||
tableOffset := flatbuffers.GetIndirectOffset(buf, vectorLocation+ 4 * (start + middle))
|
||||
tableOffset := flatbuffers.GetIndirectOffset(buf, vectorLocation+4*(start+middle))
|
||||
obj := &Referrable{}
|
||||
obj.Init(buf, tableOffset)
|
||||
val := obj.Id()
|
||||
|
||||
@@ -13,7 +13,9 @@ type StatT struct {
|
||||
}
|
||||
|
||||
func (t *StatT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
if t == nil {
|
||||
return 0
|
||||
}
|
||||
idOffset := flatbuffers.UOffsetT(0)
|
||||
if t.Id != "" {
|
||||
idOffset = builder.CreateString(t.Id)
|
||||
@@ -32,7 +34,9 @@ func (rcv *Stat) UnPackTo(t *StatT) {
|
||||
}
|
||||
|
||||
func (rcv *Stat) UnPack() *StatT {
|
||||
if rcv == nil { return nil }
|
||||
if rcv == nil {
|
||||
return nil
|
||||
}
|
||||
t := &StatT{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
@@ -108,17 +112,17 @@ func (rcv *Stat) MutateCount(n uint16) bool {
|
||||
func StatKeyCompare(o1, o2 flatbuffers.UOffsetT, buf []byte) bool {
|
||||
obj1 := &Stat{}
|
||||
obj2 := &Stat{}
|
||||
obj1.Init(buf, flatbuffers.UOffsetT(len(buf)) - o1)
|
||||
obj2.Init(buf, flatbuffers.UOffsetT(len(buf)) - o2)
|
||||
obj1.Init(buf, flatbuffers.UOffsetT(len(buf))-o1)
|
||||
obj2.Init(buf, flatbuffers.UOffsetT(len(buf))-o2)
|
||||
return obj1.Count() < obj2.Count()
|
||||
}
|
||||
|
||||
func (rcv *Stat) LookupByKey(key uint16, vectorLocation flatbuffers.UOffsetT, buf []byte) bool {
|
||||
span := flatbuffers.GetUOffsetT(buf[vectorLocation - 4:])
|
||||
span := flatbuffers.GetUOffsetT(buf[vectorLocation-4:])
|
||||
start := flatbuffers.UOffsetT(0)
|
||||
for span != 0 {
|
||||
middle := span / 2
|
||||
tableOffset := flatbuffers.GetIndirectOffset(buf, vectorLocation+ 4 * (start + middle))
|
||||
tableOffset := flatbuffers.GetIndirectOffset(buf, vectorLocation+4*(start+middle))
|
||||
obj := &Stat{}
|
||||
obj.Init(buf, tableOffset)
|
||||
val := obj.Count()
|
||||
|
||||
@@ -13,7 +13,9 @@ type StructOfStructsT struct {
|
||||
}
|
||||
|
||||
func (t *StructOfStructsT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
if t == nil {
|
||||
return 0
|
||||
}
|
||||
return CreateStructOfStructs(builder, t.A.Id, t.A.Distance, t.B.A, t.B.B, t.C.Id, t.C.Distance)
|
||||
}
|
||||
func (rcv *StructOfStructs) UnPackTo(t *StructOfStructsT) {
|
||||
@@ -23,7 +25,9 @@ func (rcv *StructOfStructs) UnPackTo(t *StructOfStructsT) {
|
||||
}
|
||||
|
||||
func (rcv *StructOfStructs) UnPack() *StructOfStructsT {
|
||||
if rcv == nil { return nil }
|
||||
if rcv == nil {
|
||||
return nil
|
||||
}
|
||||
t := &StructOfStructsT{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
|
||||
@@ -11,7 +11,9 @@ type StructOfStructsOfStructsT struct {
|
||||
}
|
||||
|
||||
func (t *StructOfStructsOfStructsT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
if t == nil {
|
||||
return 0
|
||||
}
|
||||
return CreateStructOfStructsOfStructs(builder, t.A.A.Id, t.A.A.Distance, t.A.B.A, t.A.B.B, t.A.C.Id, t.A.C.Distance)
|
||||
}
|
||||
func (rcv *StructOfStructsOfStructs) UnPackTo(t *StructOfStructsOfStructsT) {
|
||||
@@ -19,7 +21,9 @@ func (rcv *StructOfStructsOfStructs) UnPackTo(t *StructOfStructsOfStructsT) {
|
||||
}
|
||||
|
||||
func (rcv *StructOfStructsOfStructs) UnPack() *StructOfStructsOfStructsT {
|
||||
if rcv == nil { return nil }
|
||||
if rcv == nil {
|
||||
return nil
|
||||
}
|
||||
t := &StructOfStructsOfStructsT{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
|
||||
@@ -12,7 +12,9 @@ type TestT struct {
|
||||
}
|
||||
|
||||
func (t *TestT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
if t == nil {
|
||||
return 0
|
||||
}
|
||||
return CreateTest(builder, t.A, t.B)
|
||||
}
|
||||
func (rcv *Test) UnPackTo(t *TestT) {
|
||||
@@ -21,7 +23,9 @@ func (rcv *Test) UnPackTo(t *TestT) {
|
||||
}
|
||||
|
||||
func (rcv *Test) UnPack() *TestT {
|
||||
if rcv == nil { return nil }
|
||||
if rcv == nil {
|
||||
return nil
|
||||
}
|
||||
t := &TestT{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
|
||||
@@ -11,7 +11,9 @@ type TestSimpleTableWithEnumT struct {
|
||||
}
|
||||
|
||||
func (t *TestSimpleTableWithEnumT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
if t == nil {
|
||||
return 0
|
||||
}
|
||||
TestSimpleTableWithEnumStart(builder)
|
||||
TestSimpleTableWithEnumAddColor(builder, t.Color)
|
||||
return TestSimpleTableWithEnumEnd(builder)
|
||||
@@ -22,7 +24,9 @@ func (rcv *TestSimpleTableWithEnum) UnPackTo(t *TestSimpleTableWithEnumT) {
|
||||
}
|
||||
|
||||
func (rcv *TestSimpleTableWithEnum) UnPack() *TestSimpleTableWithEnumT {
|
||||
if rcv == nil { return nil }
|
||||
if rcv == nil {
|
||||
return nil
|
||||
}
|
||||
t := &TestSimpleTableWithEnumT{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
|
||||
@@ -22,7 +22,9 @@ type TypeAliasesT struct {
|
||||
}
|
||||
|
||||
func (t *TypeAliasesT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
if t == nil {
|
||||
return 0
|
||||
}
|
||||
v8Offset := flatbuffers.UOffsetT(0)
|
||||
if t.V8 != nil {
|
||||
v8Length := len(t.V8)
|
||||
@@ -81,7 +83,9 @@ func (rcv *TypeAliases) UnPackTo(t *TypeAliasesT) {
|
||||
}
|
||||
|
||||
func (rcv *TypeAliases) UnPack() *TypeAliasesT {
|
||||
if rcv == nil { return nil }
|
||||
if rcv == nil {
|
||||
return nil
|
||||
}
|
||||
t := &TypeAliasesT{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
|
||||
@@ -16,7 +16,9 @@ type Vec3T struct {
|
||||
}
|
||||
|
||||
func (t *Vec3T) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
|
||||
if t == nil { return 0 }
|
||||
if t == nil {
|
||||
return 0
|
||||
}
|
||||
return CreateVec3(builder, t.X, t.Y, t.Z, t.Test1, t.Test2, t.Test3.A, t.Test3.B)
|
||||
}
|
||||
func (rcv *Vec3) UnPackTo(t *Vec3T) {
|
||||
@@ -29,7 +31,9 @@ func (rcv *Vec3) UnPackTo(t *Vec3T) {
|
||||
}
|
||||
|
||||
func (rcv *Vec3) UnPack() *Vec3T {
|
||||
if rcv == nil { return nil }
|
||||
if rcv == nil {
|
||||
return nil
|
||||
}
|
||||
t := &Vec3T{}
|
||||
rcv.UnPackTo(t)
|
||||
return t
|
||||
|
||||
Reference in New Issue
Block a user