Open lcd1232 opened 6 months ago
Hi @lcd1232 thanks for reporting, i will have to check. can you share the output of your go version
please?
go version go1.20.14 darwin/arm64
Hi @lcd1232 i am assuming you are referring to the second example?
r, _ := io.Pipe()
scanner := bufio.NewScanner(r)
msg := "Your name please? Press the Enter key when done"
fmt.Fprintln(os.Stdout, msg)
scanner.Scan()
if err := scanner.Err(); err != nil {
t.Fatal(err)
}
name := scanner.Text()
if len(name) == 0 {
t.Log("empty input")
}
t.Logf("You entered: %s\n", name)
}
It does wait for me:
Your name please? Press the Enter key when done
My go version: go version go1.21.0 darwin/arm64
However, if i execute the program in the Go playground, I get the error you are referring to: https://go.dev/play/p/h3_CPMDplJv
Are you executing the program on your own system?
Hi. I read your article https://echorand.me/posts/go-test-stdin/ and it seems like your example doesn't work it returns
fatal error: all goroutines are asleep - deadlock!