Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在 Go 中查看我的异步通道中剩余多少存储空间?
例如
a chan uint=make(chan bool, 5) a<-true fmt.Printf(a.capazity())
例如,
package main import "fmt" func main() { a := make(chan bool, 5) a <- true fmt.Println(cap(a) - len(a)) }
输出:
4