Re: [go-nuts] Nil interface/pointer

2016-09-11 Thread Kiki Sugiaman
When making an example to reproduce a problem, I try to be as general as possible. The specific context of the question is a type that wraps multiple errors. It implements the error interface. It's useful when individual error handling is inconvenient, such as inside a defer block. I ended u

Re: [go-nuts] Nil interface/pointer

2016-09-11 Thread Dan Kortschak
On Mon, 2016-09-12 at 01:17 +0100, Julian Phillips wrote: > Um, no you don't ... > > If you want to get at the actual interface type being passed in then > you > need to do the dance, but in this case the question was about the > pointer in the interface - so we don't care about the Fooer type a

Re: [go-nuts] Nil interface/pointer

2016-09-11 Thread Julian Phillips
On 12/09/2016 00:27, Dan Kortschak wrote: On Sun, 2016-09-11 at 19:41 +1000, Kiki Sugiaman wrote: Not exactly a solution for the faint hearted, hah! It's long, but not complicated, and in the context of Axel's comment would be placed in a helper of some variety. For those at home, it's necess

Re: [go-nuts] Nil interface/pointer

2016-09-11 Thread Dan Kortschak
On Sun, 2016-09-11 at 19:41 +1000, Kiki Sugiaman wrote: > Not exactly a solution for the faint hearted, hah! It's long, but not complicated, and in the context of Axel's comment would be placed in a helper of some variety. For those at home, it's necessary to take the address of the interface val

Re: [go-nuts] Nil interface/pointer

2016-09-11 Thread 'Axel Wagner' via golang-nuts
The reason is, that there should be no reason in practice to ask this question. There is nothing special about nil-pointers in a non-nil interface, they are a perfectly valid implementation of that interface. The only reason I could think of why you would need to ask that question is, if you want t

Re: [go-nuts] Nil interface/pointer

2016-09-11 Thread Kiki Sugiaman
Thanks, Dan. Not exactly a solution for the faint hearted, hah! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For mor

Re: [go-nuts] Nil interface/pointer

2016-09-10 Thread Dan Kortschak
On Sun, 2016-09-11 at 03:02 +1000, Kiki Sugiaman wrote: > If I know every possible type (that implements the interface), I can > do > a type switch. But if I don't, there's no way to do this then? reflect will help here: https://play.golang.org/p/h76XV_eTJx -- You received this message because

Re: [go-nuts] Nil interface/pointer

2016-09-10 Thread Kiki Sugiaman
Thanks, Jan. If I know every possible type (that implements the interface), I can do a type switch. But if I don't, there's no way to do this then? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receivi

Re: [go-nuts] Nil interface/pointer

2016-09-10 Thread Jan Mercl
On Sat, Sep 10, 2016 at 5:52 PM Kiki Sugiaman wrote: Question: can I determine whether f1 is nil given only f2 to check? f2 is not (the untyped) nil. The thing inside f2 is possibly (a typed) nil. For example: https://play.golang.org/p/E-It6kkgSw -- -j -- You received this message because y

[go-nuts] Nil interface/pointer

2016-09-10 Thread Kiki Sugiaman
Hi experts, Please refer to the following code: https://play.golang.org/p/m1VyGnayjl Question: can I determine whether f1 is nil given only f2 to check? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop rec