mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
14 lines
403 B
Cheetah
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 }}
|