Re: [go-nuts] Initializing Go Struct Literals

2017-08-22 Thread Tong Sun
On Tue, Aug 22, 2017 at 11:09 AM, Tong Sun wrote: > First of all, thanks a lot for your solution andrey! > > Let me explain what I'm trying to do --- I'm trying to covert my struct > into map with github.com/fatih/structs > https://groups.google.com/d/msg/golang-nuts/eyYnelZF1zo/Z0IPBcArCwAJ > >

Re: [go-nuts] Initializing Go Struct Literals

2017-08-22 Thread Tong Sun
First of all, thanks a lot for your solution andrey! Let me explain what I'm trying to do --- I'm trying to covert my struct into map with github.com/fatih/structs https://groups.google.com/d/msg/golang-nuts/eyYnelZF1zo/Z0IPBcArCwAJ but the following gave me "panic: not struct" type Server

Re: [go-nuts] Initializing Go Struct Literals

2017-08-22 Thread Konstantin Khomoutov
On Tue, Aug 22, 2017 at 07:38:03AM -0700, Tong Sun wrote: > How to initialize a go struct like the following? > > type Server struct { > Namestring > ID int32 > Enabled bool > } This type definition looks pretty much OK. > s := struct { > Servers []Server{ > { >

Re: [go-nuts] Initializing Go Struct Literals

2017-08-22 Thread Jan Mercl
On Tue, Aug 22, 2017 at 4:38 PM Tong Sun wrote: https://play.golang.org/p/mKdRevvsH0 -- -j -- 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

Re: [go-nuts] Initializing Go Struct Literals

2017-08-22 Thread andrey mirtchovski
It's not immediately obvious what you're trying to do, but here's one possible solution: https://play.golang.org/p/wrrDlvDISq On Tue, Aug 22, 2017 at 8:38 AM, Tong Sun wrote: > Hi, > > How to initialize a go struct like the following? > > type Server struct { > Name

[go-nuts] Initializing Go Struct Literals

2017-08-22 Thread Tong Sun
Hi, How to initialize a go struct like the following? type Server struct { Namestring ID int32 Enabled bool } s := struct { Servers []Server{ { Name:"Arslan", ID: 123456, Enabled: true, }, { Name:"Arslan",