Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot debug this particular example #67

Open
cristianmtr opened this issue Oct 20, 2015 · 1 comment
Open

cannot debug this particular example #67

cristianmtr opened this issue Oct 20, 2015 · 1 comment

Comments

@cristianmtr
Copy link

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?

@jaytaylor
Copy link

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants