remove stringer in MarshalJSON
This commit is contained in:
parent
c64b41d7d9
commit
41fbf3154e
@ -64,10 +64,11 @@ func init() {
|
|||||||
|
|
||||||
// MarshalJSON is generated so {{$typename}} satisfies json.Marshaler.
|
// MarshalJSON is generated so {{$typename}} satisfies json.Marshaler.
|
||||||
func (r {{$typename}}) MarshalJSON() ([]byte, error) {
|
func (r {{$typename}}) MarshalJSON() ([]byte, error) {
|
||||||
|
{{ if not $noStringer -}}
|
||||||
if s, ok := interface{}(r).(fmt.Stringer); ok {
|
if s, ok := interface{}(r).(fmt.Stringer); ok {
|
||||||
return json.Marshal(s.String())
|
return json.Marshal(s.String())
|
||||||
}
|
}
|
||||||
s, ok := _{{$typename}}ValueToName[r]
|
{{ end }}s, ok := _{{$typename}}ValueToName[r]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("invalid {{$typename}}: %d", r)
|
return nil, fmt.Errorf("invalid {{$typename}}: %d", r)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user