package flatbuffersimport ()type (// A SOffsetT stores a signed offset into arbitrary data.SOffsetTint32// A UOffsetT stores an unsigned offset into vector data.UOffsetTuint32// A VOffsetT stores an unsigned offset in a vtable.VOffsetTuint16)const (// VtableMetadataFields is the count of metadata fields in each vtable.VtableMetadataFields = 2)// GetByte decodes a little-endian byte from a byte slice.func ( []byte) byte {returnbyte(GetUint8())}// GetBool decodes a little-endian bool from a byte slice.func ( []byte) bool {return [0] == 1}// GetUint8 decodes a little-endian uint8 from a byte slice.func ( []byte) ( uint8) { = uint8([0])return}// GetUint16 decodes a little-endian uint16 from a byte slice.func ( []byte) ( uint16) { _ = [1] // Force one bounds check. See: golang.org/issue/14808 |= uint16([0]) |= uint16([1]) << 8return}// GetUint32 decodes a little-endian uint32 from a byte slice.func ( []byte) ( uint32) { _ = [3] // Force one bounds check. See: golang.org/issue/14808 |= uint32([0]) |= uint32([1]) << 8 |= uint32([2]) << 16 |= uint32([3]) << 24return}// GetUint64 decodes a little-endian uint64 from a byte slice.func ( []byte) ( uint64) { _ = [7] // Force one bounds check. See: golang.org/issue/14808 |= uint64([0]) |= uint64([1]) << 8 |= uint64([2]) << 16 |= uint64([3]) << 24 |= uint64([4]) << 32 |= uint64([5]) << 40 |= uint64([6]) << 48 |= uint64([7]) << 56return}// GetInt8 decodes a little-endian int8 from a byte slice.func ( []byte) ( int8) { = int8([0])return}// GetInt16 decodes a little-endian int16 from a byte slice.func ( []byte) ( int16) { _ = [1] // Force one bounds check. See: golang.org/issue/14808 |= int16([0]) |= int16([1]) << 8return}// GetInt32 decodes a little-endian int32 from a byte slice.func ( []byte) ( int32) { _ = [3] // Force one bounds check. See: golang.org/issue/14808 |= int32([0]) |= int32([1]) << 8 |= int32([2]) << 16 |= int32([3]) << 24return}// GetInt64 decodes a little-endian int64 from a byte slice.func ( []byte) ( int64) { _ = [7] // Force one bounds check. See: golang.org/issue/14808 |= int64([0]) |= int64([1]) << 8 |= int64([2]) << 16 |= int64([3]) << 24 |= int64([4]) << 32 |= int64([5]) << 40 |= int64([6]) << 48 |= int64([7]) << 56return}// GetFloat32 decodes a little-endian float32 from a byte slice.func ( []byte) float32 { := GetUint32()returnmath.Float32frombits()}// GetFloat64 decodes a little-endian float64 from a byte slice.func ( []byte) float64 { := GetUint64()returnmath.Float64frombits()}// GetUOffsetT decodes a little-endian UOffsetT from a byte slice.func ( []byte) UOffsetT {returnUOffsetT(GetUint32())}// GetSOffsetT decodes a little-endian SOffsetT from a byte slice.func ( []byte) SOffsetT {returnSOffsetT(GetInt32())}// GetVOffsetT decodes a little-endian VOffsetT from a byte slice.func ( []byte) VOffsetT {returnVOffsetT(GetUint16())}// WriteByte encodes a little-endian uint8 into a byte slice.func ( []byte, byte) {WriteUint8(, uint8())}// WriteBool encodes a little-endian bool into a byte slice.func ( []byte, bool) { [0] = 0if { [0] = 1 }}// WriteUint8 encodes a little-endian uint8 into a byte slice.func ( []byte, uint8) { [0] = byte()}// WriteUint16 encodes a little-endian uint16 into a byte slice.func ( []byte, uint16) { _ = [1] // Force one bounds check. See: golang.org/issue/14808 [0] = byte() [1] = byte( >> 8)}// WriteUint32 encodes a little-endian uint32 into a byte slice.func ( []byte, uint32) { _ = [3] // Force one bounds check. See: golang.org/issue/14808 [0] = byte() [1] = byte( >> 8) [2] = byte( >> 16) [3] = byte( >> 24)}// WriteUint64 encodes a little-endian uint64 into a byte slice.func ( []byte, uint64) { _ = [7] // Force one bounds check. See: golang.org/issue/14808 [0] = byte() [1] = byte( >> 8) [2] = byte( >> 16) [3] = byte( >> 24) [4] = byte( >> 32) [5] = byte( >> 40) [6] = byte( >> 48) [7] = byte( >> 56)}// WriteInt8 encodes a little-endian int8 into a byte slice.func ( []byte, int8) { [0] = byte()}// WriteInt16 encodes a little-endian int16 into a byte slice.func ( []byte, int16) { _ = [1] // Force one bounds check. See: golang.org/issue/14808 [0] = byte() [1] = byte( >> 8)}// WriteInt32 encodes a little-endian int32 into a byte slice.func ( []byte, int32) { _ = [3] // Force one bounds check. See: golang.org/issue/14808 [0] = byte() [1] = byte( >> 8) [2] = byte( >> 16) [3] = byte( >> 24)}// WriteInt64 encodes a little-endian int64 into a byte slice.func ( []byte, int64) { _ = [7] // Force one bounds check. See: golang.org/issue/14808 [0] = byte() [1] = byte( >> 8) [2] = byte( >> 16) [3] = byte( >> 24) [4] = byte( >> 32) [5] = byte( >> 40) [6] = byte( >> 48) [7] = byte( >> 56)}// WriteFloat32 encodes a little-endian float32 into a byte slice.func ( []byte, float32) {WriteUint32(, math.Float32bits())}// WriteFloat64 encodes a little-endian float64 into a byte slice.func ( []byte, float64) {WriteUint64(, math.Float64bits())}// WriteVOffsetT encodes a little-endian VOffsetT into a byte slice.func ( []byte, VOffsetT) {WriteUint16(, uint16())}// WriteSOffsetT encodes a little-endian SOffsetT into a byte slice.func ( []byte, SOffsetT) {WriteInt32(, int32())}// WriteUOffsetT encodes a little-endian UOffsetT into a byte slice.func ( []byte, UOffsetT) {WriteUint32(, uint32())}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.