Documentation ¶
Index ¶
- Variables
- func CompactTextString(obj interface{}) string
- func DecodeVarint(buf []byte) (x uint64, n int)
- func EncodeVarint(x uint64) []byte
- func Marshal(raw interface{}) ([]byte, error)
- func MarshalBool(b *Buffer, fieldIndex uint64, value bool) error
- func MarshalBoolSlice(b *Buffer, fieldIndex uint64, value []bool) error
- func MarshalBytes(b *Buffer, fieldIndex uint64, value []byte) error
- func MarshalFloat32(b *Buffer, fieldIndex uint64, value float32) error
- func MarshalFloat32Slice(b *Buffer, fieldIndex uint64, value []float32) error
- func MarshalFloat64(b *Buffer, fieldIndex uint64, value float64) error
- func MarshalFloat64Slice(b *Buffer, fieldIndex uint64, value []float64) error
- func MarshalInt32(b *Buffer, fieldIndex uint64, value int32) error
- func MarshalInt32Slice(b *Buffer, fieldIndex uint64, value []int32) error
- func MarshalInt64(b *Buffer, fieldIndex uint64, value int64) error
- func MarshalInt64Slice(b *Buffer, fieldIndex uint64, value []int64) error
- func MarshalString(b *Buffer, fieldIndex uint64, value string) error
- func MarshalStringSlice(b *Buffer, fieldIndex uint64, value []string) error
- func MarshalStruct(b *Buffer, fieldIndex uint64, msg Struct) error
- func MarshalTextString(obj interface{}) string
- func MarshalUInt32(b *Buffer, fieldIndex uint64, value uint32) error
- func MarshalUInt32Slice(b *Buffer, fieldIndex uint64, value []uint32) error
- func MarshalUInt64(b *Buffer, fieldIndex uint64, value uint64) error
- func MarshalUInt64Slice(b *Buffer, fieldIndex uint64, value []uint64) error
- func Size(raw interface{}) int
- func SizeBool(fieldIndex uint64, value bool) int
- func SizeBoolSlice(fieldIndex uint64, value []bool) int
- func SizeBytes(fieldIndex uint64, value []byte) int
- func SizeFloat32(fieldIndex uint64, value float32) int
- func SizeFloat32Slice(fieldIndex uint64, value []float32) (ret int)
- func SizeFloat64(fieldIndex uint64, value float64) int
- func SizeFloat64Slice(fieldIndex uint64, value []float64) (ret int)
- func SizeInt32(fieldIndex uint64, value int32) int
- func SizeInt32Slice(fieldIndex uint64, value []int32) (ret int)
- func SizeInt64(fieldIndex uint64, value int64) int
- func SizeInt64Slice(fieldIndex uint64, value []int64) (ret int)
- func SizeString(fieldIndex uint64, value string) int
- func SizeStringSlice(fieldIndex uint64, value []string) (ret int)
- func SizeStruct(fieldIndex uint64, msg Struct) int
- func SizeUInt32(fieldIndex uint64, value uint32) int
- func SizeUInt32Slice(fieldIndex uint64, value []uint32) (ret int)
- func SizeUInt64(fieldIndex uint64, value uint64) int
- func SizeUInt64Slice(fieldIndex uint64, value []uint64) (ret int)
- func SizeVarint(x uint64) int
- func Unmarshal(data []byte, raw interface{}) (err error)
- func UnmarshalBool(b *Buffer, wt WireType, ret *bool) error
- func UnmarshalBoolSlice(b *Buffer, wt WireType, ret *[]bool) error
- func UnmarshalBytes(b *Buffer, wt WireType, ret *[]byte) error
- func UnmarshalFloat32(b *Buffer, wt WireType, ret *float32) error
- func UnmarshalFloat32Slice(b *Buffer, wt WireType, ret *[]float32) error
- func UnmarshalFloat64(b *Buffer, wt WireType, ret *float64) error
- func UnmarshalFloat64Slice(b *Buffer, wt WireType, ret *[]float64) error
- func UnmarshalInt32(b *Buffer, wt WireType, ret *int32) error
- func UnmarshalInt32Slice(b *Buffer, wt WireType, ret *[]int32) error
- func UnmarshalInt64(b *Buffer, wt WireType, ret *int64) error
- func UnmarshalInt64Slice(b *Buffer, wt WireType, ret *[]int64) error
- func UnmarshalString(b *Buffer, wt WireType, ret *string) error
- func UnmarshalStringSlice(b *Buffer, wt WireType, ret *[]string) error
- func UnmarshalStruct(b *Buffer, wt WireType, msgPtr Struct) error
- func UnmarshalUInt32(b *Buffer, wt WireType, ret *uint32) error
- func UnmarshalUInt32Slice(b *Buffer, wt WireType, ret *[]uint32) error
- func UnmarshalUInt64(b *Buffer, wt WireType, ret *uint64) error
- func UnmarshalUInt64Slice(b *Buffer, wt WireType, ret *[]uint64) error
- func Zigzag32(x uint64) uint64
- func Zigzag64(x uint64) uint64
- type Buffer
- func (self *Buffer) Bytes() []byte
- func (self *Buffer) BytesRemains() int
- func (self *Buffer) ConsumeBytes(size int) (ret []byte)
- func (self *Buffer) DecodeFixed32() (x uint64, err error)
- func (self *Buffer) DecodeFixed64() (x uint64, err error)
- func (self *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error)
- func (self *Buffer) DecodeStringBytes() (s string, err error)
- func (self *Buffer) DecodeVarint() (x uint64, err error)
- func (self *Buffer) DecodeZigzag32() (x uint64, err error)
- func (self *Buffer) DecodeZigzag64() (x uint64, err error)
- func (self *Buffer) EncodeFixed32(x uint64) error
- func (self *Buffer) EncodeFixed64(x uint64) error
- func (self *Buffer) EncodeRawBytes(b []byte) error
- func (self *Buffer) EncodeStringBytes(s string) error
- func (self *Buffer) EncodeVarint(x uint64) error
- func (self *Buffer) EncodeZigzag32(x uint64) error
- func (self *Buffer) EncodeZigzag64(x uint64) error
- func (self *Buffer) Reset()
- func (self *Buffer) SetBuf(s []byte)
- type Struct
- type TextMarshaler
- type WireType
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func CompactTextString ¶
func CompactTextString(obj interface{}) string
func DecodeVarint ¶
func EncodeVarint ¶
EncodeVarint returns the varint encoding of x. This is the format for the int32, int64, uint32, uint64, bool, and enum protocol buffer types. Not used by the package itself, but helpful to clients wishing to use the same encoding.
func MarshalFloat32Slice ¶
func MarshalFloat64Slice ¶
func MarshalStringSlice ¶
func MarshalTextString ¶
func MarshalTextString(obj interface{}) string
func MarshalUInt32Slice ¶
func MarshalUInt64Slice ¶
func SizeBoolSlice ¶
func SizeFloat32 ¶
func SizeFloat32Slice ¶
func SizeFloat64 ¶
func SizeFloat64Slice ¶
func SizeInt32Slice ¶
func SizeInt64Slice ¶
func SizeString ¶
func SizeStringSlice ¶
func SizeStruct ¶
func SizeUInt32 ¶
func SizeUInt32Slice ¶
func SizeUInt64 ¶
func SizeUInt64Slice ¶
func SizeVarint ¶
SizeVarint returns the varint encoding size of an integer.
func UnmarshalFloat32Slice ¶
func UnmarshalFloat64Slice ¶
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
A Buffer is a buffer manager for marshaling and unmarshaling protocol buffers. It may be reused between invocations to reduce memory usage. It is not necessary to use a Buffer; the global functions Marshal and Unmarshal create a temporary Buffer and are fine for most applications.
func NewBuffer ¶
NewBuffer allocates a new Buffer and initializes its internal data to the contents of the argument slice.
func (*Buffer) BytesRemains ¶
func (*Buffer) ConsumeBytes ¶
func (*Buffer) DecodeFixed32 ¶
DecodeFixed32 reads a 32-bit integer from the Buffer. This is the format for the fixed32, sfixed32, and float protocol buffer types.
func (*Buffer) DecodeFixed64 ¶
DecodeFixed64 reads a 64-bit integer from the Buffer. This is the format for the fixed64, sfixed64, and double protocol buffer types.
func (*Buffer) DecodeRawBytes ¶
DecodeRawBytes reads a count-delimited byte buffer from the Buffer. This is the format used for the bytes protocol buffer type and for embedded messages.
func (*Buffer) DecodeStringBytes ¶
DecodeStringBytes reads an encoded string from the Buffer. This is the format used for the proto2 string type.
func (*Buffer) DecodeVarint ¶
DecodeVarint reads a varint-encoded integer from the Buffer. This is the format for the int32, int64, uint32, uint64, bool, and enum protocol buffer types.
func (*Buffer) DecodeZigzag32 ¶
DecodeZigzag32 reads a zigzag-encoded 32-bit integer from the Buffer. This is the format used for the sint32 protocol buffer type.
func (*Buffer) DecodeZigzag64 ¶
DecodeZigzag64 reads a zigzag-encoded 64-bit integer from the Buffer. This is the format used for the sint64 protocol buffer type.
func (*Buffer) EncodeFixed32 ¶
EncodeFixed32 writes a 32-bit integer to the Buffer. This is the format for the fixed32, sfixed32, and float protocol buffer types.
func (*Buffer) EncodeFixed64 ¶
EncodeFixed64 writes a 64-bit integer to the Buffer. This is the format for the fixed64, sfixed64, and double protocol buffer types.
func (*Buffer) EncodeRawBytes ¶
EncodeRawBytes writes a count-delimited byte buffer to the Buffer. This is the format used for the bytes protocol buffer type and for embedded messages.
func (*Buffer) EncodeStringBytes ¶
EncodeStringBytes writes an encoded string to the Buffer. This is the format used for the proto2 string type.
func (*Buffer) EncodeVarint ¶
EncodeVarint writes a varint-encoded integer to the Buffer. This is the format for the int32, int64, uint32, uint64, bool, and enum protocol buffer types.
func (*Buffer) EncodeZigzag32 ¶
EncodeZigzag32 writes a zigzag-encoded 32-bit integer to the Buffer. This is the format used for the sint32 protocol buffer type.
func (*Buffer) EncodeZigzag64 ¶
EncodeZigzag64 writes a zigzag-encoded 64-bit integer to the Buffer. This is the format used for the sint64 protocol buffer type.
type TextMarshaler ¶
type TextMarshaler struct { Compact bool // use compact text format (one line). IgnoreDefault bool // Do not output value when value equals its default value OriginalString bool // Do not output string as byte CompactBytesSize int // 将二进制在指定大小后缩减显示 }
TextMarshaler is a configurable text format marshaler.
func (*TextMarshaler) Marshal ¶
func (self *TextMarshaler) Marshal(w io.Writer, obj interface{}) error
func (*TextMarshaler) Text ¶
func (self *TextMarshaler) Text(obj interface{}) string