1
0
mirror of https://github.com/golang/go synced 2024-11-21 18:14:42 -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:
Rob Pike 2011-01-26 10:41:32 -08:00
parent bba20fc1fa
commit a64e63227a

View File

@ -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 &lt;- true
}(<b>v</b>)