Flatbuffers:用字节而不是bool设置的表bool值
我的表在为go编译时,最终使用GetByte和PrependByteSlot,而不是Bool替代项(GetBool、PrependBoolSlot) 我能做些什么来改变这一点吗? 如果不是,我在哪里可以找到字节将等于0或1(假/真)的确认 下面的表格显示了这种确切的行为:Flatbuffers:用字节而不是bool设置的表bool值,flatbuffers,Flatbuffers,我的表在为go编译时,最终使用GetByte和PrependByteSlot,而不是Bool替代项(GetBool、PrependBoolSlot) 我能做些什么来改变这一点吗? 如果不是,我在哪里可以找到字节将等于0或1(假/真)的确认 下面的表格显示了这种确切的行为: table BooleanContent { value:bool = false; } 以下是生成的文件: // Code generated by the FlatBuffers compiler. DO NOT E
table BooleanContent {
value:bool = false;
}
以下是生成的文件:
// Code generated by the FlatBuffers compiler. DO NOT EDIT.
package GatewayProtocol
import (
flatbuffers "github.com/google/flatbuffers/go"
)
type BooleanContent struct {
_tab flatbuffers.Table
}
func GetRootAsBooleanContent(buf []byte, offset flatbuffers.UOffsetT) *BooleanContent {
n := flatbuffers.GetUOffsetT(buf[offset:])
x := &BooleanContent{}
x.Init(buf, n+offset)
return x
}
func (rcv *BooleanContent) Init(buf []byte, i flatbuffers.UOffsetT) {
rcv._tab.Bytes = buf
rcv._tab.Pos = i
}
func (rcv *BooleanContent) Table() flatbuffers.Table {
return rcv._tab
}
func (rcv *BooleanContent) Value() byte {
o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
if o != 0 {
return rcv._tab.GetByte(o + rcv._tab.Pos)
}
return 0
}
func (rcv *BooleanContent) MutateValue(n byte) bool {
return rcv._tab.MutateByteSlot(4, n)
}
func BooleanContentStart(builder *flatbuffers.Builder) {
builder.StartObject(1)
}
func BooleanContentAddValue(builder *flatbuffers.Builder, value byte) {
builder.PrependByteSlot(0, value, 0)
}
func BooleanContentEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
return builder.EndObject()
}
boolean肯定是以FlatBuffers二进制格式存储为字节的,但它没有理由不能像其他语言那样在访问时将其转换为boolean 所以这很可能是Go代码生成器中的一个bug,我会在github上提交一个问题,标记为[Go]。Done,谢谢反馈。