
Adds -chan option to the goroutines command to list only the goroutines running on a specified channel. Also when printing a variable if it is a channel also print the list of goroutines that are waiting on it.
27 lines
384 B
Go
27 lines
384 B
Go
package main
|
|
|
|
import (
|
|
"runtime"
|
|
"time"
|
|
)
|
|
|
|
func main() {
|
|
blockingchan1 := make(chan int)
|
|
blockingchan2 := make(chan int)
|
|
|
|
go sendToChan("one", blockingchan1)
|
|
go sendToChan("two", blockingchan1)
|
|
go recvFromChan(blockingchan2)
|
|
time.Sleep(time.Second)
|
|
|
|
runtime.Breakpoint()
|
|
}
|
|
|
|
func sendToChan(name string, ch chan<- int) {
|
|
ch <- 1
|
|
}
|
|
|
|
func recvFromChan(ch <-chan int) {
|
|
<-ch
|
|
}
|