本文整理汇总了Golang中github.com/gogo/protobuf/proto.Buffer类的典型用法代码示例。如果您正苦于以下问题:Golang Buffer类的具体用法?Golang Buffer怎么用?Golang Buffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Buffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
}
开发者ID:pascaldekloe,项目名称:colfer,代码行数:35,代码来源:stdtypes.pb.go
示例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
}
开发者ID:sr,项目名称:pb,代码行数:13,代码来源:datastore.pb.go
示例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
}
}
开发者ID:pascaldekloe,项目名称:colfer,代码行数:35,代码来源:test_objects.pb.go
示例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
}
}
开发者ID:sr,项目名称:pb,代码行数:14,代码来源:datastore.pb.go
示例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
}
开发者ID:pascaldekloe,项目名称:colfer,代码行数:28,代码来源:stdtypes.pb.go
示例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
}
}
开发者ID:gyuho,项目名称:learn,代码行数:15,代码来源:rpc.pb.go
示例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
}
开发者ID:gyuho,项目名称:learn,代码行数:15,代码来源:rpc.pb.go
示例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
}
}
开发者ID:peter-edge,项目名称:protoeasy-go,代码行数:46,代码来源:datastore.pb.go
示例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
}
}
开发者ID:ericx10ng,项目名称:kapacitor,代码行数:42,代码来源:udf.pb.go
示例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
}
}
开发者ID:sr,项目名称:pb,代码行数:21,代码来源:entity.pb.go
示例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
}
}
开发者ID:fd,项目名称:protobuf,代码行数:21,代码来源:oneofembed.pb.go
示例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
}
}
开发者ID:sr,项目名称:pb,代码行数:21,代码来源:datastore.pb.go
示例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
}
}
开发者ID:bookerzzz,项目名称:letmegrpc,代码行数:21,代码来源:serve.pb.go
示例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
}
}
开发者ID:ming-hai,项目名称:cockroach,代码行数:21,代码来源:session.pb.go
示例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
}
}
开发者ID:sr,项目名称:pb,代码行数:30,代码来源:log_entry.pb.go
示例16: _Distribution_BucketOptions_OneofUnmarshaler
func _Distribution_BucketOptions_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Distribution_BucketOptions)
switch tag {
case 1: // options.linear_buckets
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Distribution_BucketOptions_Linear)
err := b.DecodeMessage(msg)
m.Options = &Distribution_BucketOptions_LinearBuckets{msg}
return true, err
case 2: // options.exponential_buckets
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Distribution_BucketOptions_Exponential)
err := b.DecodeMessage(msg)
m.Options = &Distribution_BucketOptions_ExponentialBuckets{msg}
return true, err
case 3: // options.explicit_buckets
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Distribution_BucketOptions_Explicit)
err := b.DecodeMessage(msg)
m.Options = &Distribution_BucketOptions_ExplicitBuckets{msg}
return true, err
default:
return false, nil
}
}
开发者ID:peter-edge,项目名称:protoeasy-go,代码行数:31,代码来源:distribution.pb.go
示例17: _Response_Result_OneofUnmarshaler
func _Response_Result_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Response_Result)
switch tag {
case 2: // union.ddl
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Response_Result_DDL)
err := b.DecodeMessage(msg)
m.Union = &Response_Result_DDL_{msg}
return true, err
case 3: // union.rows_affected
if wire != proto.WireVarint {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeVarint()
m.Union = &Response_Result_RowsAffected{uint32(x)}
return true, err
case 4: // union.rows
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Response_Result_Rows)
err := b.DecodeMessage(msg)
m.Union = &Response_Result_Rows_{msg}
return true, err
default:
return false, nil
}
}
开发者ID:rohanahata,项目名称:cockroach,代码行数:30,代码来源:wire.pb.go
示例18: _GqlQueryParameter_OneofUnmarshaler
func _GqlQueryParameter_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*GqlQueryParameter)
switch tag {
case 2: // parameter_type.value
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(Value)
err := b.DecodeMessage(msg)
m.ParameterType = &GqlQueryParameter_Value{msg}
return true, err
case 3: // parameter_type.cursor
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
x, err := b.DecodeRawBytes(true)
m.ParameterType = &GqlQueryParameter_Cursor{x}
return true, err
default:
return false, nil
}
}
开发者ID:sr,项目名称:pb,代码行数:22,代码来源:query.pb.go
示例19: _Descriptor_OneofUnmarshaler
func _Descriptor_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Descriptor)
switch tag {
case 1: // union.table
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(TableDescriptor)
err := b.DecodeMessage(msg)
m.Union = &Descriptor_Table{msg}
return true, err
case 2: // union.database
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(DatabaseDescriptor)
err := b.DecodeMessage(msg)
m.Union = &Descriptor_Database{msg}
return true, err
default:
return false, nil
}
}
开发者ID:rissoa,项目名称:cockroach,代码行数:23,代码来源:structured.pb.go
示例20: _Filter_OneofUnmarshaler
func _Filter_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) {
m := msg.(*Filter)
switch tag {
case 1: // filter_type.composite_filter
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(CompositeFilter)
err := b.DecodeMessage(msg)
m.FilterType = &Filter_CompositeFilter{msg}
return true, err
case 2: // filter_type.property_filter
if wire != proto.WireBytes {
return true, proto.ErrInternalBadWireType
}
msg := new(PropertyFilter)
err := b.DecodeMessage(msg)
m.FilterType = &Filter_PropertyFilter{msg}
return true, err
default:
return false, nil
}
}
开发者ID:sr,项目名称:pb,代码行数:23,代码来源:query.pb.go
注:本文中的github.com/gogo/protobuf/proto.Buffer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论