Re: [go-nuts] Named embedded structs?

2016-08-24 Thread Sam Salisbury
, Justin Israel wrote: > Is this effectively just trying to achieve namespacing within a package? > > On Thu, Aug 25, 2016 at 11:09 AM Sam Salisbury > wrote: > >> It would just mean that all embedded struct types introduce a new type >> named "(parent struct type nam

Re: [go-nuts] Named embedded structs?

2016-08-24 Thread Sam Salisbury
> > On Thu, Aug 25, 2016, 00:08 Sam Salisbury wrote: > >> Would it be nice or nasty for this to work? https://play.golang.org/ >> p/iCTKx3gF_2 >> >> Copy-pasted: >> >> type Thing struct { >> Embedded struct { >> Name string >> } >>

[go-nuts] Re: Named embedded structs?

2016-08-24 Thread Sam Salisbury
Correction: https://play.golang.org/p/T4Lq07xDgl func main() { x := Thing.Embedded{Name: "Barry"} fmt.Println(x.Name) // output: // Barry } This is what happens when I can't rely on the compiler... On Wednesday, 24 August 2016 23:07:59 UTC+1, Sam Salisbury wrote: > > Woul

[go-nuts] Named embedded structs?

2016-08-24 Thread Sam Salisbury
Would it be nice or nasty for this to work? https://play.golang.org/p/iCTKx3gF_2 Copy-pasted: type Thing struct { Embedded struct { Name string } } func main() { x := Thing.Embedded{Name: "Barry"} fmt.Println(x.Thing.Name) // output: // Barry } Seems it would be useful to me to be able to do

Re: [go-nuts] Why is reflect.ValueOf(nil map).Interface() != nil?

2016-08-09 Thread Sam Salisbury
Playground link for above code: https://play.golang.org/p/rTrkkzEjRl On Tuesday, 9 August 2016 17:48:22 UTC+1, Sam Salisbury wrote: > > Thanks for the explanation, > > The update I suggest is to add the following sentence to the end of the > reflect.Value.IsNil documentation: >

Re: [go-nuts] Why is reflect.ValueOf(nil map).Interface() != nil?

2016-08-09 Thread Sam Salisbury
Of(i).IsNil() == true // i == nil == false On Tuesday, 9 August 2016 14:43:41 UTC+1, Ian Lance Taylor wrote: > > On Tue, Aug 9, 2016 at 6:23 AM, Sam Salisbury > wrote: > > > > All this gets me thinking, is there any use case where this fact is > useful?

Re: [go-nuts] Why is reflect.ValueOf(nil map).Interface() != nil?

2016-08-09 Thread Sam Salisbury
ention this case where it differs*, only the one about it panicking on a zero reflect.Value. * IsNil returns true for an interface{} with a nil value pointer, even though '== nil' return false. On Tuesday, 9 August 2016 11:34:00 UTC+1, Jakob Borg wrote: > > 2016-08-09 10

Re: [go-nuts] Why is reflect.ValueOf(nil map).Interface() != nil?

2016-08-09 Thread Sam Salisbury
// output: >> // nil != map[string]interface {}(nil) >> } >> > > The reason the interface is non-nil in this case is described in Ian's > link. > > On Mon, Aug 8, 2016 at 1:27 PM Ian Lance Taylor > wrote: > >> On Mon, Aug 8, 2016 at 10:07 AM, Sam Sali

[go-nuts] Why is reflect.ValueOf(nil map).Interface() != nil?

2016-08-08 Thread Sam Salisbury
The code speaks for itself, I thought I was understanding reflection up until this point... It seems that the zero value of maps is nil, until you round-trip them to a reflect.Value, and they become non-nil. The code below behaves similarly for slices. package main import ( "fmt" "reflect" )

[go-nuts] [ANN] Psyringe: a concurrent dependency injector

2016-07-31 Thread Sam Salisbury
Hi Gophers, I would love some feedback on this automatically-concurrent dependency injector I wrote: https://github.com/samsalisbury/psyringe Its design stemmed from the needs of a CLI app I am writing which has a lot of external interrelated depen