package main
import ("fmt"; "time")
func subtask(done chan<- bool) {
...
done <- true
}
func main() {
done := make(chan bool) // return a reference to an underlying data structure
go subtask(done) // why not &done? perhaps since (*chan bool) cannot specify direction.
<-done
}
有直接写 <-done的
package main
import ("fmt"; "time")
func subtask(done chan<- bool) {
...
done <- true
}
func main() {
status := false
done := make(chan bool) // return a reference to an underlying data structure
go subtask(done) // why not &done? perhaps since (*chan bool) cannot specify direction.
status <-done
}
也有 status <- done 的,这里教程只是说读和写,那它在还有其他用处吗,为什么可以缩写成<- xxx这种