mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-28 07:38:04 +00:00
Merge pull request #3977 from gonzaloserrano/feature/go-generic-deserialitzation
Add a generic way to deserialize a flatbuffer in Go.
This commit is contained in:
13
go/lib.go
Normal file
13
go/lib.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package flatbuffers
|
||||
|
||||
// FlatBuffer is the interface that represents a flatbuffer.
|
||||
type FlatBuffer interface {
|
||||
Table() Table
|
||||
Init(buf []byte, i UOffsetT)
|
||||
}
|
||||
|
||||
// GetRootAs is a generic helper to initialize a FlatBuffer with the provided buffer bytes and its data offset.
|
||||
func GetRootAs(buf []byte, offset UOffsetT, fb FlatBuffer) {
|
||||
n := GetUOffsetT(buf[offset:])
|
||||
fb.Init(buf, n+offset)
|
||||
}
|
||||
Reference in New Issue
Block a user