gitlab.com/Raven-IO/raven-delve@v1.22.4/_fixtures/goroutinebreak.go (about)

     1  package main
     2  
     3  import "runtime"
     4  
     5  const N = 10
     6  
     7  func agoroutine(started chan<- struct{}, done chan<- struct{}, i int) {
     8  	started <- struct{}{}
     9  	done <- struct{}{}
    10  }
    11  
    12  func main() {
    13  	done := make(chan struct{})
    14  	started := make(chan struct{})
    15  	for i := 0; i < N; i++ {
    16  		runtime.Breakpoint()
    17  		go agoroutine(started, done, i)
    18  	}
    19  	for i := 0; i < N; i++ {
    20  		<-started
    21  	}
    22  	runtime.Gosched()
    23  	for i := 0; i < N; i++ {
    24  		<-done
    25  	}
    26  }