Re: [go-nuts] How to initialize all members of a slice

2016-10-03 Thread 'Axel Wagner' via golang-nuts
There is no way to do this but using a for-loop. In this case, it probably means adding for i, a := range p.Adr { if a.State == "" { a.State = "NY" p.Adr[i] = a } } before the last fmt.Printf. On Mon, Oct 3, 2016 at 4:57 AM, Sarah Ahmed wrote: > Hello, > I am trying to

[go-nuts] How to initialize all members of a slice

2016-10-02 Thread Sarah Ahmed
Hello, I am trying to initialize the "State" to a default value "NY" of Address slice. The following code only sets the first element's State. I do not know how many element would be in my input. Is there any easy way to do it? Thanks in advance for your help. package main import ( "encoding/js