mailgun/godebug

cannot debug this particular example

Opened this issue · 1 comments

package main

import (
  "fmt"
  "time"
  "math/rand"
)

func f(n int) {
  for i := 0; i < 10; i++ {
    fmt.Println(n, ":", i)
    amt := time.Duration(rand.Intn(250))
    _ = "breakpoint"
    time.Sleep(time.Millisecond * amt)
  }
}

func main() {
  for i := 0; i < 10; i++ {
    go f(i)
  }
  var input string
  fmt.Scanln(&input)
}

Running:

c:\Go\EXTERNAL\bin\godebug.exe run simgoroutines.go

And output:

0 : 0
1 : 0
5 : 0
4 : 0
7 : 0
2 : 0
3 : 0
8 : 0
6 : 0
9 : 0
-> _ = "breakpoint"
(godebug) 8 : 1
4 : 1
9 : 1
4 : 2
2 : 1
7 : 1
5 : 1
[...]

The program then exits when I try to issue any of the commands from godebug (h, e.g.). Any way to override the reading from stdin?

@cristianmtr Thank you for filing this. It seems obvious in hindsight, but your reference to this limitation helped me realize why godebug wasn't working right for my program!