diff --git a/concurrency.md b/concurrency.md index 0e774364..7ed696de 100644 --- a/concurrency.md +++ b/concurrency.md @@ -363,9 +363,9 @@ func CheckWebsites(wc WebsiteChecker, urls []string) map[string]bool { resultChannel := make(chan result) for _, url := range urls { - go func() { + go func(url string) { resultChannel <- result{url, wc(url)} - }() + }(url) } for i := 0; i < len(urls); i++ { @@ -392,7 +392,7 @@ left and a value on the right: ```go // Send statement -resultChannel <- result{u, wc(u)} +resultChannel <- result{url, wc(url)} ``` The next `for` loop iterates once for each of the urls. Inside we're using diff --git a/concurrency/v3/check_websites.go b/concurrency/v3/check_websites.go index 9f71a9c0..6802b804 100644 --- a/concurrency/v3/check_websites.go +++ b/concurrency/v3/check_websites.go @@ -14,9 +14,9 @@ func CheckWebsites(wc WebsiteChecker, urls []string) map[string]bool { resultChannel := make(chan result) for _, url := range urls { - go func() { + go func(url string) { resultChannel <- result{url, wc(url)} - }() + }(url) } for i := 0; i < len(urls); i++ {