本文整理匯總了Golang中github.com/gogo/protobuf/proto.Buffer類的典型用法代碼示例。如果您正苦於以下問題:Golang Buffer類的具體用法?Golang Buffer怎麽用?Golang Buffer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Buffer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: _OneofStdTypes_OneofUnmarshaler
func _OneofStdTypes_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*OneofStdTypes)
switch tag {
case 1: // OneOfStdTimes.timestamp
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
if err != nil {
return true, err
}
c := new(time.Time)
if err2 := github_com_gogo_protobuf_types.StdTimeUnmarshal(c, x); err2 != nil {
return true, err
}
m.OneOfStdTimes = &OneofStdTypes_Timestamp{c}
return true, err
case 2: // OneOfStdTimes.duration
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
if err != nil {
return true, err
}
c := new(time.Duration)
if err2 := github_com_gogo_protobuf_types.StdDurationUnmarshal(c, x); err2 != nil {
return true, err
}
m.OneOfStdTimes = &OneofStdTypes_Duration{c}
return true, err
default:
return false, nil
}
}
示例2: _CommitRequest_OneofMarshaler
func _CommitRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
m := msg.(*CommitRequest)
// transaction_selector
switch x := m.TransactionSelector.(type) {
case *CommitRequest_Transaction:
_ = b.EncodeVarint(1<<3 | proto.WireBytes)
_ = b.EncodeRawBytes(x.Transaction)
case nil:
default:
return fmt.Errorf("CommitRequest.TransactionSelector has unexpected type %T", x)
}
return nil
}
示例3: _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
}
}
示例4: _CommitRequest_OneofUnmarshaler
func _CommitRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*CommitRequest)
switch tag {
case 1: // transaction_selector.transaction
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.TransactionSelector = &CommitRequest_Transaction{x}
return true, err
default:
return false, nil
}
}
示例5: _OneofStdTypes_OneofMarshaler
func _OneofStdTypes_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
m := msg.(*OneofStdTypes)
// OneOfStdTimes
switch x := m.OneOfStdTimes.(type) {
case *OneofStdTypes_Timestamp:
_ = b.EncodeVarint(1<<3 | proto.WireBytes)
dAtA, err := github_com_gogo_protobuf_types.StdTimeMarshal(*x.Timestamp)
if err != nil {
return err
}
if err := b.EncodeRawBytes(dAtA); err != nil {
return err
}
case *OneofStdTypes_Duration:
_ = b.EncodeVarint(2<<3 | proto.WireBytes)
dAtA, err := github_com_gogo_protobuf_types.StdDurationMarshal(*x.Duration)
if err != nil {
return err
}
if err := b.EncodeRawBytes(dAtA); err != nil {
return err
}
case nil:
default:
return fmt.Errorf("OneofStdTypes.OneOfStdTimes has unexpected type %T", x)
}
return nil
}
示例6: _WatchRequest_OneofUnmarshaler
func _WatchRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*WatchRequest)
switch tag {
case 1: // request_union.create_request
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(WatchCreateRequest)
err := b.DecodeMessage(msg)
m.RequestUnion = &WatchRequest_CreateRequest{msg}
return true, err
default:
return false, nil
}
}
示例7: _WatchRequest_OneofMarshaler
func _WatchRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
m := msg.(*WatchRequest)
// request_union
switch x := m.RequestUnion.(type) {
case *WatchRequest_CreateRequest:
_ = b.EncodeVarint(1<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.CreateRequest); err != nil {
return err
}
case nil:
default:
return fmt.Errorf("WatchRequest.RequestUnion has unexpected type %T", x)
}
return nil
}
示例8: _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
}
}
示例9: _OptionValue_OneofUnmarshaler
func _OptionValue_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*OptionValue)
switch tag {
case 2: // value.boolValue
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &OptionValue_BoolValue{x != 0}
return true, err
case 3: // value.intValue
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &OptionValue_IntValue{int64(x)}
return true, err
case 4: // value.doubleValue
if wire != proto.WireFixed64 {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeFixed64()
m.Value = &OptionValue_DoubleValue{math.Float64frombits(x)}
return true, err
case 5: // value.stringValue
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Value = &OptionValue_StringValue{x}
return true, err
case 6: // value.durationValue
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Value = &OptionValue_DurationValue{int64(x)}
return true, err
default:
return false, nil
}
}
示例10: _Key_PathElement_OneofUnmarshaler
func _Key_PathElement_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Key_PathElement)
switch tag {
case 2: // id_type.id
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.IdType = &Key_PathElement_Id{int64(x)}
return true, err
case 3: // id_type.name
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.IdType = &Key_PathElement_Name{x}
return true, err
default:
return false, nil
}
}
示例11: _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
}
}
示例12: _ReadOptions_OneofUnmarshaler
func _ReadOptions_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*ReadOptions)
switch tag {
case 1: // consistency_type.read_consistency
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.ConsistencyType = &ReadOptions_ReadConsistency_{ReadOptions_ReadConsistency(x)}
return true, err
case 2: // consistency_type.transaction
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.ConsistencyType = &ReadOptions_Transaction{x}
return true, err
default:
return false, nil
}
}
示例13: _Tree_OneofUnmarshaler
func _Tree_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Tree)
switch tag {
case 1: // stuff.ValueString
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Stuff = &Tree_ValueString{x}
return true, err
case 4: // stuff.ValueNum
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Stuff = &Tree_ValueNum{x}
return true, err
default:
return false, nil
}
}
示例14: _Session_OneofUnmarshaler
func _Session_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Session)
switch tag {
case 5: // timezone.location
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Timezone = &Session_Location{x}
return true, err
case 6: // timezone.offset
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Timezone = &Session_Offset{int64(x)}
return true, err
default:
return false, nil
}
}
示例15: _LogEntry_OneofUnmarshaler
func _LogEntry_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*LogEntry)
switch tag {
case 2: // payload.proto_payload
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(google_protobuf1.Any)
err := b.DecodeMessage(msg)
m.Payload = &LogEntry_ProtoPayload{msg}
return true, err
case 3: // payload.text_payload
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeStringBytes()
m.Payload = &LogEntry_TextPayload{x}
return true, err
case 6: // payload.json_payload
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(google_protobuf2.Struct)
err := b.DecodeMessage(msg)
m.Payload = &LogEntry_JsonPayload{msg}
return true, err
default:
return false, nil
}
}