mirror of
https://github.com/golang/go
synced 2024-11-22 00:04:41 -07:00
faq: fix minor errors in programs reported by Wojciech Mikanik
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/4114041
This commit is contained in:
parent
bba20fc1fa
commit
a64e63227a
@ -793,7 +793,7 @@ Consider the following program:
|
||||
func main() {
|
||||
done := make(chan bool)
|
||||
|
||||
values = []string{ "a", "b", "c" }
|
||||
values := []string{ "a", "b", "c" }
|
||||
for _, v := range values {
|
||||
go func() {
|
||||
fmt.Println(v)
|
||||
@ -802,7 +802,7 @@ func main() {
|
||||
}
|
||||
|
||||
// wait for all goroutines to complete before exiting
|
||||
for i := range values {
|
||||
for _ = range values {
|
||||
<-done
|
||||
}
|
||||
}
|
||||
@ -823,7 +823,7 @@ could modify the inner loop to read:
|
||||
|
||||
<pre>
|
||||
for _, v := range values {
|
||||
go func(<b>u</b>) {
|
||||
go func(<b>u</b> string) {
|
||||
fmt.Println(<b>u</b>)
|
||||
done <- true
|
||||
}(<b>v</b>)
|
||||
|
Loading…
Reference in New Issue
Block a user