In a for loop in Golang that does HTTP GET requests to a group of links, what would be the best approach to joining the output of each HTTP JSON response under one single array object?
for i := 0; i < len(servers.Sites); i++ {
req, err := http.NewRequest(http.MethodGet, servers.Sites[i].URLs, nil)
if err != nil {
log.Println(err)
}
}
I would like to view the responses joined under one object, like this, under the “vm” object:
output := Output{
Success: true,
Vm: <JSON outputs here, each separated by comma>
}
Does this do what you want? Based on the error I get on the Go playground, it looks like that environment isn’t configured to make network requests, so I’m not sure if it’s accurate or not.