Re: [go-nuts] Use of NoMethod type for custom marshaling

2019-09-15 Thread Jake Montgomery
On Sunday, September 15, 2019 at 1:26:06 AM UTC-4, Sathish VJ wrote: > > Yes, that makes sense. Thank you. > > The example I wrote was concocted. But I've seen others do it on their > own types too, which didn't make sense at all. Maybe they were just > copy-pasting similar code from elsewhere

Re: [go-nuts] Use of NoMethod type for custom marshaling

2019-09-14 Thread Sathish VJ
Yes, that makes sense. Thank you. The example I wrote was concocted. But I've seen others do it on their own types too, which didn't make sense at all. Maybe they were just copy-pasting similar code from elsewhere. On Saturday, 14 September 2019 20:20:49 UTC+5:30, Ben Burwell wrote: > > On S

Re: [go-nuts] Use of NoMethod type for custom marshaling

2019-09-14 Thread Ben Burwell
On Sat Sep 14, 2019 at 1:43 AM Sathish VJ wrote: > I saw some code where there is a temporary type called *noMethod* created > before performing custom marshaling. > > What is the purpose of doing this? > > type T struct { > A int > C string > } > > func (t T) MarshalJSON() (text []byte, err

[go-nuts] Use of NoMethod type for custom marshaling

2019-09-14 Thread Sathish VJ
I saw some code where there is a temporary type called *noMethod* created before performing custom marshaling. What is the purpose of doing this? type T struct { A int C string } func (t T) MarshalText() (text []byte, err error) { type noMethod T return json.Marshal(noMethod(t)) } func