Re: [go-nuts] Interactive input and "go test"

2021-11-05 Thread Amit Saha
On Fri, Nov 5, 2021 at 11:24 PM Amit Saha wrote: > > > > On Fri, 5 Nov 2021, 11:08 pm Axel Wagner, > wrote: >> >> First, to point out the obvious: It is a bad idea to have a test read from >> stdin. You should pass a separate io.Reader and use that. >> >> Next: exec.Cmd.{Stdin,Stdout,Stderr} ar

Re: [go-nuts] Interactive input and "go test"

2021-11-05 Thread Amit Saha
On Fri, 5 Nov 2021, 11:08 pm Axel Wagner, wrote: > First, to point out the obvious: It is a bad idea to have a test read from > stdin. You should pass a separate io.Reader and use that. > > Next: exec.Cmd.{Stdin,Stdout,Stderr} are all set to os.DevNull by default, > meaning you don't get any inpu

Re: [go-nuts] Interactive input and "go test"

2021-11-05 Thread 'Axel Wagner' via golang-nuts
First, to point out the obvious: It is a bad idea to have a test read from stdin. You should pass a separate io.Reader and use that. Next: exec.Cmd.{Stdin,Stdout,Stderr} are all set to os.DevNull by default, meaning you don't get any input or output. I assume - `go test` does not modify Cmd.Stdin

Re: [go-nuts] Interactive input and "go test"

2021-11-05 Thread Amit Saha
> On 5 Nov 2021, at 10:27 pm, Amit Saha wrote: > > 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

[go-nuts] Interactive input and "go test"

2021-11-05 Thread Amit Saha
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)