Cannot use (type string) as type []string in field value

Hi Guys,

I am trying to populate a struct field that has an embedded struct with a []string. Not having any luck.

Any help would be appreciated.


“just” use a []string{} literal:

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?


Because this is how you specify literal slices.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.