I have this test function: package main
import ( "bufio" "fmt" "os" "testing" ) func TestInput(t *testing.T) { scanner := bufio.NewScanner(os.Stdin) 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.Log(name) } When i run it via go test -v, this is what i get (TLDR; terminates without waiting for the interactive input): % go test -v === RUN TestInput Your name please? Press the Enter key when done stdin_test.go:21: empty input stdin_test.go:23: --- PASS: TestInput (0.00s) PASS ok test 0.370s However, when i compile the test and then run the binary, it waits for me to enter the input: % go test -c % ./test.test Your name please? Press the Enter key when done The latter behavior is more inline with what i was expecting in the first case as well. I thought may be it has something to do with the fact that go test is executing the binary (i think) after compiling, and started looking at: https://github.com/golang/go/blob/c7f2f51fed15b410dea5f608420858b401887d0a/src/cmd/go/internal/test/test.go , but can't see anything obvious. Wondering if anyone of you folks have an answer? Thanks, Amit. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/0f48fc8d-7e21-46a6-b736-90ea2f0bcbe6n%40googlegroups.com.