Merge pull request #73 from moul/dev/jhayotte/time

Add helper isFieldMessageTimeStamp
This commit is contained in:
Julien Hayotte 2017-09-18 16:22:28 +02:00 committed by GitHub
commit 1dc5500690

View File

@ -89,6 +89,7 @@ var ProtoHelpersFuncMap = template.FuncMap{
"getMessageType": getMessageType,
"getEnumValue": getEnumValue,
"isFieldMessage": isFieldMessage,
"isFieldMessageTimeStamp": isFieldMessageTimeStamp,
"isFieldRepeated": isFieldRepeated,
"haskellType": haskellType,
"goType": goType,
@ -152,6 +153,15 @@ func getEnumValue(f []*descriptor.EnumDescriptorProto, name string) []*descripto
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 {
if f.Type != nil && *f.Type == descriptor.FieldDescriptorProto_TYPE_MESSAGE {
return true