[Go] Fix bug where bytes wasn't being imported when using --gen-onefile flag (#7706)

* Fix bug one file import bug

* Create reset import function and add braces
This commit is contained in:
Michael Le
2022-12-13 02:06:48 -05:00
committed by GitHub
parent c0797b22ae
commit e1a2f688e0
2 changed files with 15 additions and 9 deletions

View File

@@ -579,12 +579,12 @@ func MonsterKeyCompare(o1, o2 flatbuffers.UOffsetT, buf []byte) bool {
func (rcv *Monster) LookupByKey(key string, vectorLocation flatbuffers.UOffsetT, buf []byte) bool {
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))
obj := &Monster{}
obj.Init(buf, tableOffset)
bKey := []byte(key)
comp := bytes.Compare(obj.Name(), bKey)
if comp > 0 {
span = middle