[go-nuts] Why not a mixture of value and pointer receiver?

2019-01-22 Thread Xinhu Liu
In "A Tour of Go " I read: In general, all methods on a given type should have either value or pointer > receivers, but not a mixture of both. But why not? Methods having value receiver can be called by both value type and pointer type. The same is for

Re: [go-nuts] Why not a mixture of value and pointer receiver?

2019-01-23 Thread Xinhu Liu
Why is that a problem? I can indeed call it on value (at line 20). I got result: > > hello > hello > Program exited. > > I am now more confusing when I come to https://golang.org/doc/faq#different_method_sets. Am Mi., 23. Jan. 2019 um 06:47 Uhr schrieb Andrei Avram < andrei.avram@gmail.com>:

Re: [go-nuts] Why not a mixture of value and pointer receiver?

2019-01-23 Thread Xinhu Liu
On the other side maybe confusion on the part of code writers if they use pointer receiver because of consistency instead of needing it? Am Mi., 23. Jan. 2019 um 00:01 Uhr schrieb Ian Lance Taylor : > On Tue, Jan 22, 2019 at 1:59 PM Xinhu Liu wrote: > > > > In "

Re: [go-nuts] Why not a mixture of value and pointer receiver?

2019-01-23 Thread Xinhu Liu
> clarifies your confusion. > > You can find such paragraph in > https://golang.org/doc/effective_go.html#pointers_vs_values > > On Wednesday, 23 January 2019 09:52:02 UTC+1, Xinhu Liu wrote: >> >> Why is that a problem? I can indeed call it on value (at line 20). I got &

Re: [go-nuts] How to append nil using reflect

2019-01-11 Thread Xinhu Liu
Hi Ian, thanks for your reply. After reading and experimenting a lot I think I understand the slight differences between nil and interface{} with nil value. The only thing I find confusing is that interface{}(nil) == nil returns true. (The reason why I use reflect on interface is that I want

Re: [go-nuts] How to append nil using reflect

2019-01-11 Thread Xinhu Liu
Hi Josh, thanks a lot. It helps me to understand interface in go. Am Sa., 12. Jan. 2019 um 00:08 Uhr schrieb Josh Humphries < jh...@bluegosling.com>: > On Fri, Jan 11, 2019 at 5:59 PM Xinhu Liu wrote: > >> Hi Ian, >> >> thanks for your reply. >> >> Aft