delve/_fixtures/changoroutines.go
Alessandro Arzilli 0b35fe6d42
proc,service,terminal: add ways to list goroutines waiting on a channel (#3481)
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.
2023-08-23 13:02:34 -07:00

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
}