本文整理匯總了Golang中github.com/nildev/account/Godeps/_workspace/src/github.com/golang/protobuf/proto.Buffer.EncodeVarint方法的典型用法代碼示例。如果您正苦於以下問題:Golang Buffer.EncodeVarint方法的具體用法?Golang Buffer.EncodeVarint怎麽用?Golang Buffer.EncodeVarint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/nildev/account/Godeps/_workspace/src/github.com/golang/protobuf/proto.Buffer
的用法示例。
在下文中一共展示了Buffer.EncodeVarint方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: _GcRule_OneofMarshaler
func _GcRule_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
m := msg.(*GcRule)
// rule
switch x := m.Rule.(type) {
case *GcRule_MaxNumVersions:
b.EncodeVarint(1<<3 | proto.WireVarint)
b.EncodeVarint(uint64(x.MaxNumVersions))
case *GcRule_MaxAge:
b.EncodeVarint(2<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.MaxAge); err != nil {
return err
}
case *GcRule_Intersection_:
b.EncodeVarint(3<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.Intersection); err != nil {
return err
}
case *GcRule_Union_:
b.EncodeVarint(4<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.Union); err != nil {
return err
}
case nil:
default:
return fmt.Errorf("GcRule.Rule has unexpected type %T", x)
}
return nil
}
示例2: _ReadRowsResponse_Chunk_OneofMarshaler
func _ReadRowsResponse_Chunk_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
m := msg.(*ReadRowsResponse_Chunk)
// chunk
switch x := m.Chunk.(type) {
case *ReadRowsResponse_Chunk_RowContents:
b.EncodeVarint(1<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.RowContents); err != nil {
return err
}
case *ReadRowsResponse_Chunk_ResetRow:
t := uint64(0)
if x.ResetRow {
t = 1
}
b.EncodeVarint(2<<3 | proto.WireVarint)
b.EncodeVarint(t)
case *ReadRowsResponse_Chunk_CommitRow:
t := uint64(0)
if x.CommitRow {
t = 1
}
b.EncodeVarint(3<<3 | proto.WireVarint)
b.EncodeVarint(t)
case nil:
default:
return fmt.Errorf("ReadRowsResponse_Chunk.Chunk has unexpected type %T", x)
}
return nil
}
示例3: _ReadRowsRequest_OneofMarshaler
func _ReadRowsRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
m := msg.(*ReadRowsRequest)
// target
switch x := m.Target.(type) {
case *ReadRowsRequest_RowKey:
b.EncodeVarint(2<<3 | proto.WireBytes)
b.EncodeRawBytes(x.RowKey)
case *ReadRowsRequest_RowRange:
b.EncodeVarint(3<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.RowRange); err != nil {
return err
}
case nil:
default:
return fmt.Errorf("ReadRowsRequest.Target has unexpected type %T", x)
}
return nil
}
示例4: _ServerArgs_OneofMarshaler
func _ServerArgs_OneofMarshaler(msg proto.Message, b *proto.Buffer) error {
m := msg.(*ServerArgs)
// argtype
switch x := m.Argtype.(type) {
case *ServerArgs_Setup:
b.EncodeVarint(1<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.Setup); err != nil {
return err
}
case *ServerArgs_Mark:
b.EncodeVarint(2<<3 | proto.WireBytes)
if err := b.EncodeMessage(x.Mark); err != nil {
return err
}
case nil:
default:
return fmt.Errorf("ServerArgs.Argtype has unexpected type %T", x)
}
return nil
}