-
Notifications
You must be signed in to change notification settings - Fork 1
Go Memes
HOA PHAN edited this page Feb 28, 2024
·
8 revisions
//https://go.dev/blog/loopvar-preview
// docker run --rm -v "$(pwd)":/go/src/app -w /go/src/app golang:1.21 go run l.go
// docker run --rm -v "$(pwd)":/go/src/app -w /go/src/app golang:1.22.0 go run l.go
func main() {
done := make(chan bool)
values := []string{"a", "b", "c"}
for _, v := range values {
go func() {
fmt.Println(v) // all 'c'
done <- true
}()
}
for _ = range values {
<-done
}
}