I am trying to embed multiple objects inside a slice, so I can later export them as JSON. The JSON should look something like this:
[
{
name: "Nginx"
version: "1.9"
},
{
name: ircd-hybrid"
version: "8.2"
}
]
So far I have this struct in Go:
type response struct {
application []struct {
name string
version string
}
}
Now (I'm not even sure if the struct is correct), I'm trying to access it this way (again, not sure if this is correct):
var d response
d[0].name = "Nginx"
d[0].version = "1.9"
And so on and so forth. However, it is not working, so I assume I went wrong somewhere. I just don't know where.