Hi Guys,
I am trying to populate a struct field that has an embedded struct with a []string. Not having any luck.
https://play.golang.org/p/H3TFxcmAaAY
Any help would be appreciated.
Thanks
Hi Guys,
I am trying to populate a struct field that has an embedded struct with a []string. Not having any luck.
https://play.golang.org/p/H3TFxcmAaAY
Any help would be appreciated.
Thanks
“just” use a []string{}
literal:
https://play.golang.org/p/tDNu6gNoRSm
Added a println to fix unused variable error.
That works. Thank you. But why does it work?
I read at least 15 JSON tutorials and never came across this pattern: []string{“randomString”}. Why the {} ? What does that say? Is that how you access an embedded field in a struct?
Cheers
Because this is how you specify literal slices.
Thanks
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.