Forked from google/flatbuffers
Use "--force-defaults" option to emit default values into final bytes. Table Start function will add all default values into builder.
- Java/C#
- Golang
flatc -g -n packet.fbs --force-defaults
// packet.fbs
namespace packet;
table Packet {
id:uint16=1234;
}
Packet.go
...
func PacketStart(builder *flatbuffers.Builder) {
builder.StartObject(1)
builder.PrependUint16Slot(0, 1234, 0)
}
...
Packet.cs
...
public static void StartPacket(FlatBufferBuilder builder) {
builder.StartTable(1);
builder.AddUshort(0, 1234, 0);
}
...
will be generated.