Refactor code to use a single channel in an idiomatic way
问题 I have the following code: package main import ( "fmt" "time" ) type Response struct { Data string Status int } func main() { var rc [10]chan Response for i := 0; i < 10; i++ { rc[i] = make(chan Response) } var responses []Response for i := 0; i < 10; i++ { go func(c chan<- Response, n int) { c <- GetData(n) close(c) }(rc[i], i) } for _, resp := range rc { responses = append(responses, <-resp) } for _, item := range responses { fmt.Printf("%+v\n", item) } } func GetData(n int) Response { time