Merge pull request #33 from moul/dev/vgheri/isRepeated
Adds helper to know if a field is a repeated one. Closes #32
This commit is contained in:
commit
cdb9580565
19
helpers.go
19
helpers.go
@ -56,11 +56,12 @@ var ProtoHelpersFuncMap = template.FuncMap{
|
|||||||
"kebabCase": func(s string) string {
|
"kebabCase": func(s string) string {
|
||||||
return strings.Replace(xstrings.ToSnakeCase(s), "_", "-", -1)
|
return strings.Replace(xstrings.ToSnakeCase(s), "_", "-", -1)
|
||||||
},
|
},
|
||||||
"getMessageType": getMessageType,
|
"getMessageType": getMessageType,
|
||||||
"isFieldMessage": isFieldMessage,
|
"isFieldMessage": isFieldMessage,
|
||||||
"goType": goType,
|
"isFieldRepeated": isFieldRepeated,
|
||||||
"httpVerb": httpVerb,
|
"goType": goType,
|
||||||
"httpPath": httpPath,
|
"httpVerb": httpVerb,
|
||||||
|
"httpPath": httpPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -89,6 +90,14 @@ func isFieldMessage(f *descriptor.FieldDescriptorProto) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isFieldRepeated(f *descriptor.FieldDescriptorProto) bool {
|
||||||
|
if f.Type != nil && f.Label != nil && *f.Label == descriptor.FieldDescriptorProto_LABEL_REPEATED {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func goType(pkg string, f *descriptor.FieldDescriptorProto) string {
|
func goType(pkg string, f *descriptor.FieldDescriptorProto) string {
|
||||||
switch *f.Type {
|
switch *f.Type {
|
||||||
case descriptor.FieldDescriptorProto_TYPE_DOUBLE:
|
case descriptor.FieldDescriptorProto_TYPE_DOUBLE:
|
||||||
|
Loading…
Reference in New Issue
Block a user