File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -115,8 +115,22 @@ func (o *GenOpts) templateFuncMap() template.FuncMap {
115
115
"full_message_type" : func (f * protogen.Message ) string {
116
116
return fmt .Sprint (f .Desc .FullName ())
117
117
},
118
+ "is_google_type" : func (f * protogen.Field ) bool {
119
+ if f .Message != nil {
120
+ return strings .HasPrefix (string (f .Message .Desc .FullName ()), "google." )
121
+ }
122
+ if f .Enum != nil {
123
+ return strings .HasPrefix (string (f .Enum .Desc .FullName ()), "google." )
124
+ }
125
+ return false
126
+ },
118
127
"type_link" : func (f * protogen.Field ) string {
128
+ // exclude google types:
129
+
119
130
if f .Message != nil {
131
+ if strings .HasPrefix (string (f .Message .Desc .FullName ()), "google." ) {
132
+ return string (f .Message .Desc .FullName ())
133
+ }
120
134
fn := fmt .Sprint (f .Message .Desc .ParentFile ().Path ())
121
135
fn = filepath .Base (fn )
122
136
fn = strings .TrimSuffix (fn , filepath .Ext (fn ))
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ Field template
111
111
***************************************************************/}}
112
112
{{define "field" -}}
113
113
| {{.Desc.Name}}{{ if .Desc.IsList }}[]{{ end }} |
114
- {{- if (is_primitive .) -}}
114
+ {{- if (or ( is_primitive .) (is_google_type .) ) -}}
115
115
{{ field_type . }}
116
116
{{- else -}}
117
117
[{{ .| field_type }}]({{ type_link . }})
You can’t perform that action at this time.
0 commit comments