change proto field type

This commit is contained in:
zhuyasen
2024-03-10 16:36:18 +08:00
parent adf3750c6f
commit a68584fead
19 changed files with 260 additions and 222 deletions

View File

@@ -956,8 +956,8 @@ func goTypeToProto(fields []tmplField) []tmplField {
field.GoType = "int32"
case "uint":
field.GoType = "uint32"
case "time.Time":
field.GoType = "int64"
case "time.Time", "*time.Time":
field.GoType = "string"
case "float32":
field.GoType = "float"
case "float64":
@@ -978,6 +978,13 @@ func goTypeToProto(fields []tmplField) []tmplField {
} else if strings.Contains(field.GoType, "[]*") {
field.GoType = "repeated " + strings.ReplaceAll(field.GoType, "[]*", "")
}
if field.GoType == "[]time.Time" {
field.GoType = "repeated string"
}
} else {
if strings.ToLower(field.Name) == "id" {
field.GoType = "uint64"
}
}
newFields = append(newFields, field)