本文整理匯總了Golang中github.com/gogo/protobuf/proto.SizeVarint函數的典型用法代碼示例。如果您正苦於以下問題:Golang SizeVarint函數的具體用法?Golang SizeVarint怎麽用?Golang SizeVarint使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了SizeVarint函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: _Value_OneofSizer
func _Value_OneofSizer(msg proto.Message) (n int) {
m := msg.(*Value)
// kind
switch x := m.Kind.(type) {
case *Value_NullValue:
n += proto.SizeVarint(1<<3 | proto.WireVarint)
n += proto.SizeVarint(uint64(x.NullValue))
case *Value_NumberValue:
n += proto.SizeVarint(2<<3 | proto.WireFixed64)
n += 8
case *Value_StringValue:
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.StringValue)))
n += len(x.StringValue)
case *Value_BoolValue:
n += proto.SizeVarint(4<<3 | proto.WireVarint)
n += 1
case *Value_StructValue:
s := proto.Size(x.StructValue)
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Value_ListValue:
s := proto.Size(x.ListValue)
n += proto.SizeVarint(6<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例2: _CommitRequest_OneofSizer
func _CommitRequest_OneofSizer(msg proto.Message) (n int) {
m := msg.(*CommitRequest)
// transaction_selector
switch x := m.TransactionSelector.(type) {
case *CommitRequest_Transaction:
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.Transaction)))
n += len(x.Transaction)
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例3: _MsgWithOneof_OneofSizer
func _MsgWithOneof_OneofSizer(msg proto.Message) (n int) {
m := msg.(*MsgWithOneof)
// union
switch x := m.Union.(type) {
case *MsgWithOneof_Title:
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.Title)))
n += len(x.Title)
case *MsgWithOneof_Salary:
n += proto.SizeVarint(2<<3 | proto.WireVarint)
n += proto.SizeVarint(uint64(x.Salary))
case *MsgWithOneof_Country:
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.Country)))
n += len(x.Country)
case *MsgWithOneof_HomeAddress:
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.HomeAddress)))
n += len(x.HomeAddress)
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例4: _Mutation_OneofSizer
func _Mutation_OneofSizer(msg proto.Message) (n int) {
m := msg.(*Mutation)
// operation
switch x := m.Operation.(type) {
case *Mutation_Insert:
s := proto.Size(x.Insert)
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Mutation_Update:
s := proto.Size(x.Update)
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Mutation_Upsert:
s := proto.Size(x.Upsert)
n += proto.SizeVarint(6<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Mutation_Delete:
s := proto.Size(x.Delete)
n += proto.SizeVarint(7<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例5: _WatchRequest_OneofSizer
func _WatchRequest_OneofSizer(msg proto.Message) (n int) {
m := msg.(*WatchRequest)
// request_union
switch x := m.RequestUnion.(type) {
case *WatchRequest_CreateRequest:
s := proto.Size(x.CreateRequest)
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例6: _Bar_OneofSizer
func _Bar_OneofSizer(msg proto1.Message) (n int) {
m := msg.(*Bar)
// pick
switch x := m.Pick.(type) {
case *Bar_A:
n += proto1.SizeVarint(11<<3 | proto1.WireVarint)
n += 1
case *Bar_B:
n += proto1.SizeVarint(12<<3 | proto1.WireVarint)
n += 1
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例7: _ReadOptions_OneofSizer
func _ReadOptions_OneofSizer(msg proto.Message) (n int) {
m := msg.(*ReadOptions)
// consistency_type
switch x := m.ConsistencyType.(type) {
case *ReadOptions_ReadConsistency_:
n += proto.SizeVarint(1<<3 | proto.WireVarint)
n += proto.SizeVarint(uint64(x.ReadConsistency))
case *ReadOptions_Transaction:
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.Transaction)))
n += len(x.Transaction)
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例8: _Session_OneofSizer
func _Session_OneofSizer(msg proto.Message) (n int) {
m := msg.(*Session)
// timezone
switch x := m.Timezone.(type) {
case *Session_Location:
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.Location)))
n += len(x.Location)
case *Session_Offset:
n += proto.SizeVarint(6<<3 | proto.WireVarint)
n += proto.SizeVarint(uint64(x.Offset))
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例9: _Key_PathElement_OneofSizer
func _Key_PathElement_OneofSizer(msg proto.Message) (n int) {
m := msg.(*Key_PathElement)
// id_type
switch x := m.IdType.(type) {
case *Key_PathElement_Id:
n += proto.SizeVarint(2<<3 | proto.WireVarint)
n += proto.SizeVarint(uint64(x.Id))
case *Key_PathElement_Name:
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.Name)))
n += len(x.Name)
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例10: _GqlQueryParameter_OneofSizer
func _GqlQueryParameter_OneofSizer(msg proto.Message) (n int) {
m := msg.(*GqlQueryParameter)
// parameter_type
switch x := m.ParameterType.(type) {
case *GqlQueryParameter_Value:
s := proto.Size(x.Value)
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *GqlQueryParameter_Cursor:
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(len(x.Cursor)))
n += len(x.Cursor)
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例11: _Filter_OneofSizer
func _Filter_OneofSizer(msg proto.Message) (n int) {
m := msg.(*Filter)
// filter_type
switch x := m.FilterType.(type) {
case *Filter_CompositeFilter:
s := proto.Size(x.CompositeFilter)
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Filter_PropertyFilter:
s := proto.Size(x.PropertyFilter)
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例12: _RunQueryRequest_OneofSizer
func _RunQueryRequest_OneofSizer(msg proto.Message) (n int) {
m := msg.(*RunQueryRequest)
// query_type
switch x := m.QueryType.(type) {
case *RunQueryRequest_Query:
s := proto.Size(x.Query)
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *RunQueryRequest_GqlQuery:
s := proto.Size(x.GqlQuery)
n += proto.SizeVarint(7<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例13: _OneofStdTypes_OneofSizer
func _OneofStdTypes_OneofSizer(msg proto.Message) (n int) {
m := msg.(*OneofStdTypes)
// OneOfStdTimes
switch x := m.OneOfStdTimes.(type) {
case *OneofStdTypes_Timestamp:
s := github_com_gogo_protobuf_types.SizeOfStdTime(*x.Timestamp)
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *OneofStdTypes_Duration:
s := github_com_gogo_protobuf_types.SizeOfStdDuration(*x.Duration)
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例14: _Operation_OneofSizer
func _Operation_OneofSizer(msg proto.Message) (n int) {
m := msg.(*Operation)
// result
switch x := m.Result.(type) {
case *Operation_Error:
s := proto.Size(x.Error)
n += proto.SizeVarint(4<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Operation_Response:
s := proto.Size(x.Response)
n += proto.SizeVarint(5<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}
示例15: _Distribution_BucketOptions_OneofSizer
func _Distribution_BucketOptions_OneofSizer(msg proto.Message) (n int) {
m := msg.(*Distribution_BucketOptions)
// options
switch x := m.Options.(type) {
case *Distribution_BucketOptions_LinearBuckets:
s := proto.Size(x.LinearBuckets)
n += proto.SizeVarint(1<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Distribution_BucketOptions_ExponentialBuckets:
s := proto.Size(x.ExponentialBuckets)
n += proto.SizeVarint(2<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case *Distribution_BucketOptions_ExplicitBuckets:
s := proto.Size(x.ExplicitBuckets)
n += proto.SizeVarint(3<<3 | proto.WireBytes)
n += proto.SizeVarint(uint64(s))
n += s
case nil:
default:
panic(fmt.Sprintf("proto: unexpected type %T in oneof", x))
}
return n
}