How much is left on my channel?

Is there a way to see how much memory is left in my asynchronous channel in Go?

for instance

a chan uint=make(chan bool, 5) a<-true fmt.Printf(a.capazity()) 
+4
source share
1 answer

For instance,

 package main import "fmt" func main() { a := make(chan bool, 5) a <- true fmt.Println(cap(a) - len(a)) } 

Output:

 4 
+6
source

Source: https://habr.com/ru/post/1488494/


All Articles