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
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