mailgun / mailgun/godebug

cannot debug this particular example

Open
#67 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
2.5k
Forks
102
PR merge metrics
No merged PRs in 30d

Description

``` go
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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the supplied Go goroutine example using `godebug.exe run simgoroutines.go`, then trace how debugger commands and the target program's stdin are handled. Done means the target can call `fmt.Scanln` without causing debugger commands such as `h` to exit the session.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.