I've the following function which iterate on list of response and if success print ok or error, at the end (after the function finished to execute) I need to return http 200 (if ok or 200 conditon is valid always) or http 500 if failure (even one failure) .I can use some flag (which I want to avoid) but is there a cleaner way to do it in Golang?
func getResults(results chan resultsList) {
for res := range results {
if res.Data != "ok" && res.Data != 200 {
fmt.Println("error")
} else {
fmt.Printf("finish time %s \n", res.Name)
}
}
}