You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
current: batman
options: { batman: something, robin: another }
You are trying to unmarshal a YAML mapping into a Go slice. You could try this with:
current: batman
options:
- batman: something
- robin: another
But it still won't work. The problem lies in that the yaml lib looks in Target for a field name 'batman' or 'robin' to put the values into, and of course none exists. (inline only affects structs contained by other structs and isn't relevant here afaik.)
The problem is that the slice is of the element type Target. Change it to:
type Target map[string]string
And things will start working. Or, use this kind of YAML:
current: batman
options:
- label: batman
endpoint: something
- label: robin
endpoint: another
Hi! How can I unmarshal an array of struct elements? (I've tried with ,inline, without , inline)
thanks!
The text was updated successfully, but these errors were encountered: