本文整理汇总了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
}