Add helper isFieldMessageTimeStamp

This commit is contained in:
jhayotte 2017-09-18 15:04:39 +02:00
parent a921a29c7e
commit dab343fc15

View File

@ -89,6 +89,7 @@ var ProtoHelpersFuncMap = template.FuncMap{
"getMessageType": getMessageType, "getMessageType": getMessageType,
"getEnumValue": getEnumValue, "getEnumValue": getEnumValue,
"isFieldMessage": isFieldMessage, "isFieldMessage": isFieldMessage,
"isFieldMessageTimeStamp": isFieldMessageTimeStamp,
"isFieldRepeated": isFieldRepeated, "isFieldRepeated": isFieldRepeated,
"haskellType": haskellType, "haskellType": haskellType,
"goType": goType, "goType": goType,
@ -152,6 +153,15 @@ func getEnumValue(f []*descriptor.EnumDescriptorProto, name string) []*descripto
return nil return nil
} }
func isFieldMessageTimeStamp(f *descriptor.FieldDescriptorProto) bool {
if f.Type != nil && *f.Type == descriptor.FieldDescriptorProto_TYPE_MESSAGE {
if strings.Compare(*f.Name, "timestamp") == 0 {
return true
}
}
return false
}
func isFieldMessage(f *descriptor.FieldDescriptorProto) bool { func isFieldMessage(f *descriptor.FieldDescriptorProto) bool {
if f.Type != nil && *f.Type == descriptor.FieldDescriptorProto_TYPE_MESSAGE { if f.Type != nil && *f.Type == descriptor.FieldDescriptorProto_TYPE_MESSAGE {
return true return true