Added MarshalJSON and UnmarshalJSON comments to template to prevent

golint from complaining.
This commit is contained in:
Daved 2015-04-06 20:47:20 -07:00
parent a3cb655480
commit 362f6fe4ec

View File

@ -42,6 +42,7 @@ func init() {
} }
} }
// MarshalJSON returns *r as the JSON encoding of r.
func (r {{$typename}}) MarshalJSON() ([]byte, error) { func (r {{$typename}}) MarshalJSON() ([]byte, error) {
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())
@ -53,6 +54,7 @@ func (r {{$typename}}) MarshalJSON() ([]byte, error) {
return json.Marshal(s) return json.Marshal(s)
} }
// UnmarshalJSON sets *r to a copy of data.
func (r *{{$typename}}) UnmarshalJSON(data []byte) error { func (r *{{$typename}}) UnmarshalJSON(data []byte) error {
var s string var s string
if err := json.Unmarshal(data, &s); err != nil { if err := json.Unmarshal(data, &s); err != nil {