Files
ent/examples/entcpkg/ent/template/stringer.tmpl
2021-03-12 16:41:12 +02:00

14 lines
403 B
Cheetah

{{ define "model/additional/stringer" }}
{{/* A template that adds the "GoString" method to all generated models on the same file they are defined. */}}
// GoString implements the fmt.GoStringer interface.
func ({{ $.Receiver }} *{{ $.Name }}) GoString() string {
json, err := json.MarshalIndent({{ $.Receiver }}, "", "\t")
if err != nil {
return err.Error()
}
return string(json)
}
{{ end }}