Here is an example code from the book "The Go Programming Language" by Donovan and Kernighan. It's about a simple concurrent web crawler.
https://github.com/adonovan/gopl.io/blob/master/ch8/crawl3/findlinks.go
When I put this part (in the main
function)
seen := make(map[string]bool)
for list := range worklist {
for _, link := range list {
....
}
}
}
in front of
for i := 0; i < 20; i++ {
go func() {
for link := range unseenLinks {
...
}
}()
}
the code does not work. Why is this?