本文整理匯總了Golang中limbo/services/protobuf/protoc-gen-gogo/descriptor.FieldDescriptorProto.Options方法的典型用法代碼示例。如果您正苦於以下問題:Golang FieldDescriptorProto.Options方法的具體用法?Golang FieldDescriptorProto.Options怎麽用?Golang FieldDescriptorProto.Options使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類limbo/services/protobuf/protoc-gen-gogo/descriptor.FieldDescriptorProto
的用法示例。
在下文中一共展示了FieldDescriptorProto.Options方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetMapKeyField
func (g *Generator) GetMapKeyField(field, keyField *descriptor.FieldDescriptorProto) *descriptor.FieldDescriptorProto {
if !gogoproto.IsCastKey(field) {
return keyField
}
keyField = proto.Clone(keyField).(*descriptor.FieldDescriptorProto)
if keyField.Options == nil {
keyField.Options = &descriptor.FieldOptions{}
}
keyType := gogoproto.GetCastKey(field)
if err := proto.SetExtension(keyField.Options, gogoproto.E_Casttype, &keyType); err != nil {
g.Fail(err.Error())
}
return keyField
}
示例2: GetMapValueField
func (g *Generator) GetMapValueField(field, valField *descriptor.FieldDescriptorProto) *descriptor.FieldDescriptorProto {
if !gogoproto.IsCastValue(field) && gogoproto.IsNullable(field) {
return valField
}
valField = proto.Clone(valField).(*descriptor.FieldDescriptorProto)
if valField.Options == nil {
valField.Options = &descriptor.FieldOptions{}
}
if valType := gogoproto.GetCastValue(field); len(valType) > 0 {
if err := proto.SetExtension(valField.Options, gogoproto.E_Casttype, &valType); err != nil {
g.Fail(err.Error())
}
}
nullable := gogoproto.IsNullable(field)
if err := proto.SetExtension(valField.Options, gogoproto.E_Nullable, &nullable); err != nil {
g.Fail(err.Error())
}
return valField
}
示例3: GetColumn
func GetColumn(field *pb.FieldDescriptorProto) *ColumnDescriptor {
if field.Options == nil {
field.Options = &pb.FieldOptions{}
}
v, _ := proto.GetExtension(field.Options, E_Column)
if v == nil {
if j, _ := proto.GetExtension(field.Options, E_Join); j != nil {
return nil
}
v = &ColumnDescriptor{}
proto.SetExtension(field.Options, E_Column, v)
}
c := v.(*ColumnDescriptor)
if c.Ignore {
return nil
}
return c
}