summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Demeyer <jeroen.demeyer@be-mobile.com>2023-04-26 07:19:07 +0200
committerGitHub <noreply@github.com>2023-04-26 05:19:07 +0000
commit6c8a8d054d27b5149d2daf90609a47214e55d633 (patch)
tree02c1ba821a1c1eb2ff96372ec5f1e06a14bb15db
parent63495b935a06cba8f3b09e21fb79f08d50f06648 (diff)
downloadflatbuffers-6c8a8d054d27b5149d2daf90609a47214e55d633.tar.gz
flatbuffers-6c8a8d054d27b5149d2daf90609a47214e55d633.tar.bz2
flatbuffers-6c8a8d054d27b5149d2daf90609a47214e55d633.zip
Go: make generated code more compliant to "go fmt" (#7907)
Co-authored-by: Derek Bailey <derekbailey@google.com>
-rw-r--r--examples/go-echo/hero/Warrior.go13
-rw-r--r--examples/go-echo/net/Request.go8
-rw-r--r--examples/go-echo/net/Response.go8
-rw-r--r--src/idl_gen_go.cpp33
-rw-r--r--tests/MyGame/Example/Ability.go8
-rw-r--r--tests/MyGame/Example/Any.go8
-rw-r--r--tests/MyGame/Example/AnyAmbiguousAliases.go8
-rw-r--r--tests/MyGame/Example/AnyUniqueAliases.go8
-rw-r--r--tests/MyGame/Example/Monster.go32
-rw-r--r--tests/MyGame/Example/Referrable.go16
-rw-r--r--tests/MyGame/Example/Stat.go16
-rw-r--r--tests/MyGame/Example/StructOfStructs.go8
-rw-r--r--tests/MyGame/Example/StructOfStructsOfStructs.go8
-rw-r--r--tests/MyGame/Example/Test.go8
-rw-r--r--tests/MyGame/Example/TestSimpleTableWithEnum.go8
-rw-r--r--tests/MyGame/Example/TypeAliases.go8
-rw-r--r--tests/MyGame/Example/Vec3.go8
-rw-r--r--tests/MyGame/Example2/Monster.go8
-rw-r--r--tests/MyGame/InParentNamespace.go8
19 files changed, 143 insertions, 79 deletions
diff --git a/examples/go-echo/hero/Warrior.go b/examples/go-echo/hero/Warrior.go
index 857697e1..0e9802c1 100644
--- a/examples/go-echo/hero/Warrior.go
+++ b/examples/go-echo/hero/Warrior.go
@@ -12,8 +12,13 @@ type WarriorT struct {
}
func (t *WarriorT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
- if t == nil { return 0 }
- nameOffset := builder.CreateString(t.Name)
+ if t == nil {
+ return 0
+ }
+ nameOffset := flatbuffers.UOffsetT(0)
+ if t.Name != "" {
+ nameOffset = builder.CreateString(t.Name)
+ }
WarriorStart(builder)
WarriorAddName(builder, nameOffset)
WarriorAddHp(builder, t.Hp)
@@ -26,7 +31,9 @@ func (rcv *Warrior) UnPackTo(t *WarriorT) {
}
func (rcv *Warrior) UnPack() *WarriorT {
- if rcv == nil { return nil }
+ if rcv == nil {
+ return nil
+ }
t := &WarriorT{}
rcv.UnPackTo(t)
return t
diff --git a/examples/go-echo/net/Request.go b/examples/go-echo/net/Request.go
index b2449c1c..4c833626 100644
--- a/examples/go-echo/net/Request.go
+++ b/examples/go-echo/net/Request.go
@@ -13,7 +13,9 @@ type RequestT struct {
}
func (t *RequestT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
- if t == nil { return 0 }
+ if t == nil {
+ return 0
+ }
playerOffset := t.Player.Pack(builder)
RequestStart(builder)
RequestAddPlayer(builder, playerOffset)
@@ -25,7 +27,9 @@ func (rcv *Request) UnPackTo(t *RequestT) {
}
func (rcv *Request) UnPack() *RequestT {
- if rcv == nil { return nil }
+ if rcv == nil {
+ return nil
+ }
t := &RequestT{}
rcv.UnPackTo(t)
return t
diff --git a/examples/go-echo/net/Response.go b/examples/go-echo/net/Response.go
index 57e6b353..a9d1f437 100644
--- a/examples/go-echo/net/Response.go
+++ b/examples/go-echo/net/Response.go
@@ -13,7 +13,9 @@ type ResponseT struct {
}
func (t *ResponseT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
- if t == nil { return 0 }
+ if t == nil {
+ return 0
+ }
playerOffset := t.Player.Pack(builder)
ResponseStart(builder)
ResponseAddPlayer(builder, playerOffset)
@@ -25,7 +27,9 @@ func (rcv *Response) UnPackTo(t *ResponseT) {
}
func (rcv *Response) UnPack() *ResponseT {
- if rcv == nil { return nil }
+ if rcv == nil {
+ return nil
+ }
t := &ResponseT{}
rcv.UnPackTo(t)
return t
diff --git a/src/idl_gen_go.cpp b/src/idl_gen_go.cpp
index f2ffc3e7..0f2882b7 100644
--- a/src/idl_gen_go.cpp
+++ b/src/idl_gen_go.cpp
@@ -541,7 +541,7 @@ class GoGenerator : public BaseGenerator {
GenReceiver(struct_def, code_ptr);
code += " " + namer_.Field(field) + "ByKey";
code += "(obj *" + TypeName(field);
- code += ", key " + NativeType(key_field.value.type) + ") bool" +
+ code += ", key " + NativeType(key_field.value.type) + ") bool " +
OffsetPrefix(field);
code += "\t\tx := rcv._tab.Vector(o)\n";
code += "\t\treturn ";
@@ -920,8 +920,8 @@ class GoGenerator : public BaseGenerator {
code += "o1, o2 flatbuffers.UOffsetT, buf []byte) bool {\n";
code += "\tobj1 := &" + namer_.Type(struct_def) + "{}\n";
code += "\tobj2 := &" + namer_.Type(struct_def) + "{}\n";
- code += "\tobj1.Init(buf, flatbuffers.UOffsetT(len(buf)) - o1)\n";
- code += "\tobj2.Init(buf, flatbuffers.UOffsetT(len(buf)) - o2)\n";
+ code += "\tobj1.Init(buf, flatbuffers.UOffsetT(len(buf))-o1)\n";
+ code += "\tobj2.Init(buf, flatbuffers.UOffsetT(len(buf))-o2)\n";
if (IsString(field.value.type)) {
code += "\treturn string(obj1." + namer_.Function(field.name) + "()) < ";
code += "string(obj2." + namer_.Function(field.name) + "())\n";
@@ -943,13 +943,13 @@ class GoGenerator : public BaseGenerator {
code += "key " + NativeType(field.value.type) + ", ";
code += "vectorLocation flatbuffers.UOffsetT, ";
code += "buf []byte) bool {\n";
- code += "\tspan := flatbuffers.GetUOffsetT(buf[vectorLocation - 4:])\n";
+ code += "\tspan := flatbuffers.GetUOffsetT(buf[vectorLocation-4:])\n";
code += "\tstart := flatbuffers.UOffsetT(0)\n";
if (IsString(field.value.type)) { code += "\tbKey := []byte(key)\n"; }
code += "\tfor span != 0 {\n";
code += "\t\tmiddle := span / 2\n";
code += "\t\ttableOffset := flatbuffers.GetIndirectOffset(buf, ";
- code += "vectorLocation+ 4 * (start + middle))\n";
+ code += "vectorLocation+4*(start+middle))\n";
code += "\t\tobj := &" + namer_.Type(struct_def) + "{}\n";
code += "\t\tobj.Init(buf, tableOffset)\n";
@@ -1060,8 +1060,8 @@ class GoGenerator : public BaseGenerator {
code += "\t\treturn &" +
WrapInNameSpaceAndTrack(&enum_def, NativeName(enum_def)) +
- "{ Type: " + namer_.EnumVariant(enum_def, ev) +
- ", Value: x.UnPack() }\n";
+ "{Type: " + namer_.EnumVariant(enum_def, ev) +
+ ", Value: x.UnPack()}\n";
}
code += "\t}\n";
code += "\treturn nil\n";
@@ -1074,7 +1074,7 @@ class GoGenerator : public BaseGenerator {
code += "func (t *" + NativeName(struct_def) +
") Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {\n";
- code += "\tif t == nil { return 0 }\n";
+ code += "\tif t == nil {\n\t\treturn 0\n\t}\n";
for (auto it = struct_def.fields.vec.begin();
it != struct_def.fields.vec.end(); ++it) {
const FieldDef &field = **it;
@@ -1144,8 +1144,7 @@ class GoGenerator : public BaseGenerator {
if (field.value.type.struct_def->fixed) continue;
code += "\t" + offset + " := t." + field_field + ".Pack(builder)\n";
} else if (field.value.type.base_type == BASE_TYPE_UNION) {
- code += "\t" + offset + " := t." + field_field + ".Pack(builder)\n";
- code += "\t\n";
+ code += "\t" + offset + " := t." + field_field + ".Pack(builder)\n\n";
} else {
FLATBUFFERS_ASSERT(0);
}
@@ -1261,7 +1260,7 @@ class GoGenerator : public BaseGenerator {
code += "func (rcv *" + struct_type + ") UnPack() *" +
NativeName(struct_def) + " {\n";
- code += "\tif rcv == nil { return nil }\n";
+ code += "\tif rcv == nil {\n\t\treturn nil\n\t}\n";
code += "\tt := &" + NativeName(struct_def) + "{}\n";
code += "\trcv.UnPackTo(t)\n";
code += "\treturn t\n";
@@ -1273,7 +1272,7 @@ class GoGenerator : public BaseGenerator {
code += "func (t *" + NativeName(struct_def) +
") Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {\n";
- code += "\tif t == nil { return 0 }\n";
+ code += "\tif t == nil {\n\t\treturn 0\n\t}\n";
code += "\treturn Create" + namer_.Type(struct_def) + "(builder";
StructPackArgs(struct_def, "", code_ptr);
code += ")\n";
@@ -1317,7 +1316,7 @@ class GoGenerator : public BaseGenerator {
code += "func (rcv *" + namer_.Type(struct_def) + ") UnPack() *" +
NativeName(struct_def) + " {\n";
- code += "\tif rcv == nil { return nil }\n";
+ code += "\tif rcv == nil {\n\t\treturn nil\n\t}\n";
code += "\tt := &" + NativeName(struct_def) + "{}\n";
code += "\trcv.UnPackTo(t)\n";
code += "\treturn t\n";
@@ -1505,15 +1504,17 @@ class GoGenerator : public BaseGenerator {
code += "package " + name_space_name + "\n\n";
if (needs_imports) {
code += "import (\n";
+ // standard imports, in alphabetical order for go fmt
if (needs_bytes_import_) code += "\t\"bytes\"\n";
- // math is needed to support non-finite scalar default values.
- if (needs_math_import_) { code += "\t\"math\"\n"; }
- if (is_enum) { code += "\t\"strconv\"\n"; }
if (!parser_.opts.go_import.empty()) {
code += "\tflatbuffers \"" + parser_.opts.go_import + "\"\n";
} else {
code += "\tflatbuffers \"github.com/google/flatbuffers/go\"\n";
}
+ // math is needed to support non-finite scalar default values.
+ if (needs_math_import_) { code += "\t\"math\"\n"; }
+ if (is_enum) { code += "\t\"strconv\"\n"; }
+
if (tracked_imported_namespaces_.size() > 0) {
code += "\n";
for (auto it = tracked_imported_namespaces_.begin();
diff --git a/tests/MyGame/Example/Ability.go b/tests/MyGame/Example/Ability.go
index ae869aaf..922c0e4a 100644
--- a/tests/MyGame/Example/Ability.go
+++ b/tests/MyGame/Example/Ability.go
@@ -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
diff --git a/tests/MyGame/Example/Any.go b/tests/MyGame/Example/Any.go
index 3b7f6295..9d56df27 100644
--- a/tests/MyGame/Example/Any.go
+++ b/tests/MyGame/Example/Any.go
@@ -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
}
diff --git a/tests/MyGame/Example/AnyAmbiguousAliases.go b/tests/MyGame/Example/AnyAmbiguousAliases.go
index 83e5f7d8..6cfb12f7 100644
--- a/tests/MyGame/Example/AnyAmbiguousAliases.go
+++ b/tests/MyGame/Example/AnyAmbiguousAliases.go
@@ -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
}
diff --git a/tests/MyGame/Example/AnyUniqueAliases.go b/tests/MyGame/Example/AnyUniqueAliases.go
index b36e61d9..0bf17b09 100644
--- a/tests/MyGame/Example/AnyUniqueAliases.go
+++ b/tests/MyGame/Example/AnyUniqueAliases.go
@@ -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
}
diff --git a/tests/MyGame/Example/Monster.go b/tests/MyGame/Example/Monster.go
index 899b5103..cc6453b1 100644
--- a/tests/MyGame/Example/Monster.go
+++ b/tests/MyGame/Example/Monster.go
@@ -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)
diff --git a/tests/MyGame/Example/Referrable.go b/tests/MyGame/Example/Referrable.go
index beaf8574..f6248bb7 100644
--- a/tests/MyGame/Example/Referrable.go
+++ b/tests/MyGame/Example/Referrable.go
@@ -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()
diff --git a/tests/MyGame/Example/Stat.go b/tests/MyGame/Example/Stat.go
index 9c7238c1..5855abf1 100644
--- a/tests/MyGame/Example/Stat.go
+++ b/tests/MyGame/Example/Stat.go
@@ -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()
diff --git a/tests/MyGame/Example/StructOfStructs.go b/tests/MyGame/Example/StructOfStructs.go
index 22281b66..234c795e 100644
--- a/tests/MyGame/Example/StructOfStructs.go
+++ b/tests/MyGame/Example/StructOfStructs.go
@@ -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
diff --git a/tests/MyGame/Example/StructOfStructsOfStructs.go b/tests/MyGame/Example/StructOfStructsOfStructs.go
index b8f32a0d..90094aa9 100644
--- a/tests/MyGame/Example/StructOfStructsOfStructs.go
+++ b/tests/MyGame/Example/StructOfStructsOfStructs.go
@@ -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
diff --git a/tests/MyGame/Example/Test.go b/tests/MyGame/Example/Test.go
index 14917117..d7efcf4f 100644
--- a/tests/MyGame/Example/Test.go
+++ b/tests/MyGame/Example/Test.go
@@ -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
diff --git a/tests/MyGame/Example/TestSimpleTableWithEnum.go b/tests/MyGame/Example/TestSimpleTableWithEnum.go
index 97f72de7..f491ccd8 100644
--- a/tests/MyGame/Example/TestSimpleTableWithEnum.go
+++ b/tests/MyGame/Example/TestSimpleTableWithEnum.go
@@ -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
diff --git a/tests/MyGame/Example/TypeAliases.go b/tests/MyGame/Example/TypeAliases.go
index cb79778d..e13311ee 100644
--- a/tests/MyGame/Example/TypeAliases.go
+++ b/tests/MyGame/Example/TypeAliases.go
@@ -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
diff --git a/tests/MyGame/Example/Vec3.go b/tests/MyGame/Example/Vec3.go
index 16a05cde..ae0cb1e7 100644
--- a/tests/MyGame/Example/Vec3.go
+++ b/tests/MyGame/Example/Vec3.go
@@ -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
diff --git a/tests/MyGame/Example2/Monster.go b/tests/MyGame/Example2/Monster.go
index b01755ce..4062f7c2 100644
--- a/tests/MyGame/Example2/Monster.go
+++ b/tests/MyGame/Example2/Monster.go
@@ -10,7 +10,9 @@ type MonsterT struct {
}
func (t *MonsterT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
- if t == nil { return 0 }
+ if t == nil {
+ return 0
+ }
MonsterStart(builder)
return MonsterEnd(builder)
}
@@ -19,7 +21,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
diff --git a/tests/MyGame/InParentNamespace.go b/tests/MyGame/InParentNamespace.go
index 832dea15..37c44c18 100644
--- a/tests/MyGame/InParentNamespace.go
+++ b/tests/MyGame/InParentNamespace.go
@@ -10,7 +10,9 @@ type InParentNamespaceT struct {
}
func (t *InParentNamespaceT) Pack(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
- if t == nil { return 0 }
+ if t == nil {
+ return 0
+ }
InParentNamespaceStart(builder)
return InParentNamespaceEnd(builder)
}
@@ -19,7 +21,9 @@ func (rcv *InParentNamespace) UnPackTo(t *InParentNamespaceT) {
}
func (rcv *InParentNamespace) UnPack() *InParentNamespaceT {
- if rcv == nil { return nil }
+ if rcv == nil {
+ return nil
+ }
t := &InParentNamespaceT{}
rcv.UnPackTo(t)
return t