本文整理汇总了Golang中github.com/maditya/protobuf/proto.Buffer.DecodeVarint方法的典型用法代码示例。如果您正苦于以下问题:Golang Buffer.DecodeVarint方法的具体用法?Golang Buffer.DecodeVarint怎么用?Golang Buffer.DecodeVarint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/maditya/protobuf/proto.Buffer
的用法示例。
在下文中一共展示了Buffer.DecodeVarint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: _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
}
}
示例2: _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
}
}
示例3: _Bar_OneofUnmarshaler
func _Bar_OneofUnmarshaler(msg proto1.Message, tag, wire int, b *proto1.Buffer) (bool, error) {
m := msg.(*Bar)
switch tag {
case 11: // pick.a
if wire != proto1.WireVarint {
return true, proto1.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Pick = &Bar_A{x != 0}
return true, err
case 12: // pick.b
if wire != proto1.WireVarint {
return true, proto1.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Pick = &Bar_B{x != 0}
return true, err
default:
return false, nil
}
}
示例4: _Communique_OneofUnmarshaler
func _Communique_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Communique)
switch tag {
case 5: // union.number
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Union = &Communique_Number{int32(x)}
return true, err
case 6: // union.name
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Union = &Communique_Name{x}
return true, err
case 7: // union.data
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.Union = &Communique_Data{x}
return true, err
case 8: // union.temp_c
if wire != proto.WireFixed64 {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeFixed64()
m.Union = &Communique_TempC{math.Float64frombits(x)}
return true, err
case 9: // union.height
if wire != proto.WireFixed32 {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeFixed32()
m.Union = &Communique_Height{math.Float32frombits(uint32(x))}
return true, err
case 10: // union.today
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Union = &Communique_Today{Days(x)}
return true, err
case 11: // union.maybe
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Union = &Communique_Maybe{x != 0}
return true, err
case 12: // union.delta
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeZigzag32()
m.Union = &Communique_Delta_{int32(x)}
return true, err
case 13: // union.msg
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Reply)
err := b.DecodeMessage(msg)
m.Union = &Communique_Msg{msg}
return true, err
case 14: // union.somegroup
if wire != proto.WireStartGroup {
return true, proto.ErrInternalBadWireType
}
msg := new(Communique_SomeGroup)
err := b.DecodeGroup(msg)
m.Union = &Communique_Somegroup{msg}
return true, err
default:
return false, nil
}
}