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

@ -84,22 +84,23 @@ var ProtoHelpersFuncMap = template.FuncMap{
"trimstr": func(cutset, s string) string { "trimstr": func(cutset, s string) string {
return strings.Trim(s, cutset) return strings.Trim(s, cutset)
}, },
"snakeCase": xstrings.ToSnakeCase, "snakeCase": xstrings.ToSnakeCase,
"getProtoFile": getProtoFile, "getProtoFile": getProtoFile,
"getMessageType": getMessageType, "getMessageType": getMessageType,
"getEnumValue": getEnumValue, "getEnumValue": getEnumValue,
"isFieldMessage": isFieldMessage, "isFieldMessage": isFieldMessage,
"isFieldRepeated": isFieldRepeated, "isFieldMessageTimeStamp": isFieldMessageTimeStamp,
"haskellType": haskellType, "isFieldRepeated": isFieldRepeated,
"goType": goType, "haskellType": haskellType,
"goTypeWithPackage": goTypeWithPackage, "goType": goType,
"jsType": jsType, "goTypeWithPackage": goTypeWithPackage,
"jsSuffixReserved": jsSuffixReservedKeyword, "jsType": jsType,
"namespacedFlowType": namespacedFlowType, "jsSuffixReserved": jsSuffixReservedKeyword,
"httpVerb": httpVerb, "namespacedFlowType": namespacedFlowType,
"httpPath": httpPath, "httpVerb": httpVerb,
"shortType": shortType, "httpPath": httpPath,
"urlHasVarsFromMessage": urlHasVarsFromMessage, "shortType": shortType,
"urlHasVarsFromMessage": urlHasVarsFromMessage,
} }
func init() { func init() {
@ -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