本文整理汇总了Golang中github.com/golang/protobuf/proto.Buffer.DecodeVarint方法的典型用法代码示例。如果您正苦于以下问题:Golang Buffer.DecodeVarint方法的具体用法?Golang Buffer.DecodeVarint怎么用?Golang Buffer.DecodeVarint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/golang/protobuf/proto.Buffer
的用法示例。
在下文中一共展示了Buffer.DecodeVarint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: _ModifyColumnFamiliesRequest_Modification_OneofUnmarshaler
func _ModifyColumnFamiliesRequest_Modification_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*ModifyColumnFamiliesRequest_Modification)
switch tag {
case 2: // mod.create
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(ColumnFamily)
err := b.DecodeMessage(msg)
m.Mod = &ModifyColumnFamiliesRequest_Modification_Create{msg}
return true, err
case 3: // mod.update
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(ColumnFamily)
err := b.DecodeMessage(msg)
m.Mod = &ModifyColumnFamiliesRequest_Modification_Update{msg}
return true, err
case 4: // mod.drop
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Mod = &ModifyColumnFamiliesRequest_Modification_Drop{x != 0}
return true, err
default:
return false, nil
}
}
示例2: _ReadRowsResponse_Chunk_OneofUnmarshaler
func _ReadRowsResponse_Chunk_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*ReadRowsResponse_Chunk)
switch tag {
case 1: // chunk.row_contents
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(google_bigtable_v11.Family)
err := b.DecodeMessage(msg)
m.Chunk = &ReadRowsResponse_Chunk_RowContents{msg}
return true, err
case 2: // chunk.reset_row
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Chunk = &ReadRowsResponse_Chunk_ResetRow{x != 0}
return true, err
case 3: // chunk.commit_row
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Chunk = &ReadRowsResponse_Chunk_CommitRow{x != 0}
return true, err
default:
return false, nil
}
}
示例3: Unmarshal
// Unmarshal deserializes a `NsReadWriteSet`
func (nsRW *NsReadWriteSet) Unmarshal(buf *proto.Buffer) error {
var err error
if nsRW.NameSpace, err = buf.DecodeStringBytes(); err != nil {
return err
}
var numReads uint64
if numReads, err = buf.DecodeVarint(); err != nil {
return err
}
for i := 0; i < int(numReads); i++ {
r := &KVRead{}
if err = r.Unmarshal(buf); err != nil {
return err
}
nsRW.Reads = append(nsRW.Reads, r)
}
var numWrites uint64
if numWrites, err = buf.DecodeVarint(); err != nil {
return err
}
for i := 0; i < int(numWrites); i++ {
w := &KVWrite{}
if err = w.Unmarshal(buf); err != nil {
return err
}
nsRW.Writes = append(nsRW.Writes, w)
}
return nil
}
示例4: _MsgWithOneof_OneofUnmarshaler
func _MsgWithOneof_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*MsgWithOneof)
switch tag {
case 1: // union.title
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Union = &MsgWithOneof_Title{x}
return true, err
case 2: // union.salary
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Union = &MsgWithOneof_Salary{int64(x)}
return true, err
case 3: // union.Country
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Union = &MsgWithOneof_Country{x}
return true, err
case 4: // union.home_address
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Union = &MsgWithOneof_HomeAddress{x}
return true, err
default:
return false, nil
}
}
示例5: _Argument_OneofUnmarshaler
func _Argument_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Argument)
switch tag {
case 1: // value.number
if wire != proto.WireFixed64 {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeFixed64()
m.Value = &Argument_Number{math.Float64frombits(x)}
return true, err
case 2: // value.str
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Value = &Argument_Str{x}
return true, err
case 3: // value.boolean
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &Argument_Boolean{x != 0}
return true, err
default:
return false, nil
}
}
示例6: _GaugeResponse_OneofUnmarshaler
func _GaugeResponse_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*GaugeResponse)
switch tag {
case 2: // value.long_value
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &GaugeResponse_LongValue{int64(x)}
return true, err
case 3: // value.double_value
if wire != proto.WireFixed64 {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeFixed64()
m.Value = &GaugeResponse_DoubleValue{math.Float64frombits(x)}
return true, err
case 4: // value.string_value
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Value = &GaugeResponse_StringValue{x}
return true, err
default:
return false, nil
}
}
示例7: _Column_OneofUnmarshaler
func _Column_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Column)
switch tag {
case 1: // value.string
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Value = &Column_String_{x}
return true, err
case 2: // value.int32
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &Column_Int32{int32(x)}
return true, err
case 3: // value.int64
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &Column_Int64{int64(x)}
return true, err
case 4: // value.uint32
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &Column_Uint32{uint32(x)}
return true, err
case 5: // value.uint64
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &Column_Uint64{x}
return true, err
case 6: // value.bytes
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.Value = &Column_Bytes{x}
return true, err
case 7: // value.bool
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &Column_Bool{x != 0}
return true, err
default:
return false, nil
}
}
示例8: _Field_OneofUnmarshaler
func _Field_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Field)
switch tag {
case 2: // value.number
if wire != proto.WireFixed64 {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeFixed64()
m.Value = &Field_Number{math.Float64frombits(x)}
return true, err
case 3: // value.str
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Value = &Field_Str{x}
return true, err
case 4: // value.boolean
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &Field_Boolean{x != 0}
return true, err
case 5: // value.object
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Object)
err := b.DecodeMessage(msg)
m.Value = &Field_Object{msg}
return true, err
case 6: // value.array
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Array)
err := b.DecodeMessage(msg)
m.Value = &Field_Array{msg}
return true, err
case 7: // value.link
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Link)
err := b.DecodeMessage(msg)
m.Value = &Field_Link{msg}
return true, err
default:
return false, nil
}
}
示例9: _Value_OneofUnmarshaler
func _Value_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Value)
switch tag {
case 1: // kind.null_value
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Kind = &Value_NullValue{NullValue(x)}
return true, err
case 2: // kind.number_value
if wire != proto.WireFixed64 {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeFixed64()
m.Kind = &Value_NumberValue{math.Float64frombits(x)}
return true, err
case 3: // kind.string_value
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Kind = &Value_StringValue{x}
return true, err
case 4: // kind.bool_value
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Kind = &Value_BoolValue{x != 0}
return true, err
case 5: // kind.struct_value
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Struct)
err := b.DecodeMessage(msg)
m.Kind = &Value_StructValue{msg}
return true, err
case 6: // kind.list_value
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(ListValue)
err := b.DecodeMessage(msg)
m.Kind = &Value_ListValue{msg}
return true, err
default:
return false, nil
}
}
示例10: unmarshalTrieNodeValueFromBuffer
func unmarshalTrieNodeValueFromBuffer(buffer *proto.Buffer) []byte {
valueMarker, err := buffer.DecodeVarint()
if err != nil {
panic(fmt.Errorf("This error is not excpected: %s", err))
}
if valueMarker == 0 {
return nil
}
value, err := buffer.DecodeRawBytes(false)
if err != nil {
panic(fmt.Errorf("This error is not excpected: %s", err))
}
return value
}
示例11: _Metric_OneofUnmarshaler
func _Metric_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Metric)
switch tag {
case 9: // data.string_data
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Data = &Metric_StringData{x}
return true, err
case 10: // data.float32_data
if wire != proto.WireFixed32 {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeFixed32()
m.Data = &Metric_Float32Data{math.Float32frombits(uint32(x))}
return true, err
case 11: // data.float64_data
if wire != proto.WireFixed64 {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeFixed64()
m.Data = &Metric_Float64Data{math.Float64frombits(x)}
return true, err
case 12: // data.int32_data
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Data = &Metric_Int32Data{int32(x)}
return true, err
case 13: // data.int64_data
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Data = &Metric_Int64Data{int64(x)}
return true, err
case 14: // data.bytes_data
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.Data = &Metric_BytesData{x}
return true, err
default:
return false, nil
}
}
示例12: _Mutation_OneofUnmarshaler
func _Mutation_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Mutation)
switch tag {
case 4: // operation.insert
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Entity)
err := b.DecodeMessage(msg)
m.Operation = &Mutation_Insert{msg}
return true, err
case 5: // operation.update
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Entity)
err := b.DecodeMessage(msg)
m.Operation = &Mutation_Update{msg}
return true, err
case 6: // operation.upsert
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Entity)
err := b.DecodeMessage(msg)
m.Operation = &Mutation_Upsert{msg}
return true, err
case 7: // operation.delete
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Key)
err := b.DecodeMessage(msg)
m.Operation = &Mutation_Delete{msg}
return true, err
case 8: // conflict_detection_strategy.base_version
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.ConflictDetectionStrategy = &Mutation_BaseVersion{int64(x)}
return true, err
default:
return false, nil
}
}
示例13: unmarshalValueWithMarker
func (chaincodeStateDelta *ChaincodeStateDelta) unmarshalValueWithMarker(buffer *proto.Buffer) ([]byte, error) {
valueMarker, err := buffer.DecodeVarint()
if err != nil {
return nil, fmt.Errorf("Error unmarshaling state delta : %s", err)
}
if valueMarker == 0 {
return nil, nil
}
value, err := buffer.DecodeRawBytes(false)
if err != nil {
return nil, fmt.Errorf("Error unmarhsaling state delta : %s", err)
}
// protobuff makes an empty []byte into a nil. So, assigning an empty byte array explicitly
if value == nil {
value = []byte{}
}
return value, nil
}
示例14: _Flag_OneofUnmarshaler
func _Flag_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Flag)
switch tag {
case 1: // flag.reserved
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Flag = &Flag_Reserved_{Flag_Reserved(x)}
return true, err
case 2: // flag.custom
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Flag = &Flag_Custom{x}
return true, err
default:
return false, nil
}
}
示例15: _Response_OneofUnmarshaler
func _Response_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Response)
switch tag {
case 1: // event.turn
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Event = &Response_Turn{Response_State(x)}
return true, err
case 2: // event.lightup
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Event = &Response_Lightup{Color(x)}
return true, err
default:
return false, nil
}
}