
An internal breakpoint condition shouldn't ever error: * use a ThreadContext to evaluate conditions if a goroutine isn't available * evaluate runtime.curg to a fake g variable containing only `goid == 0` when there is no current goroutine Fixes #2113
36 lines
460 B
Go
36 lines
460 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime"
|
|
"sync"
|
|
)
|
|
|
|
func coroutine(i int, start, finish *sync.WaitGroup) {
|
|
defer finish.Done()
|
|
|
|
j := i * 2
|
|
|
|
if i == 99 {
|
|
runtime.Breakpoint()
|
|
start.Done()
|
|
} else {
|
|
start.Wait()
|
|
}
|
|
|
|
fmt.Println("hello ", i, j)
|
|
fmt.Println("goodbye", i, j)
|
|
}
|
|
|
|
func main() {
|
|
i := 0
|
|
var start, finish sync.WaitGroup
|
|
start.Add(1)
|
|
for ; i < 100; i++ {
|
|
finish.Add(1)
|
|
go coroutine(i, &start, &finish)
|
|
}
|
|
finish.Wait()
|
|
println(i)
|
|
}
|