Golang app using sync.WaitGroup & channels never exits
问题 I use sync.WaitGroup , defer wg.Close() and wg.Wait() to wait for my goroutines to complete. The program do wait, but it never exits. This is my program (runnable): package main import ( "fmt" "io" "log" "net/http" "os" "sync" ) var symbols = []string{ "ASSA-B.ST", "ELUX-B.ST", "HM-B.ST", } func main() { fmt.Println("fetching quotes...") fetchedSymbols := make(chan string) var wg sync.WaitGroup wg.Add(len(symbols)) for _, symbol := range symbols { go fetchSymbol(symbol, &wg, fetchedSymbols) }