Skip to content

cmd/go: 'go run' doesn't provide os.Stdin to the program it's running. #2875

@gopherbot

Description

@gopherbot

by consalus:

What steps will reproduce the problem?
1. 'go run' a program that takes input from Stdin.
2. It gets EOF, since it's run with os.DevNull as Stdin.


Which compiler are you using (5g, 6g, 8g, gccgo)?
The 'go' tool, since we no longer use the compiler directory.
But it's certainly using 6g.

Which operating system are you using?
Mac OS X 10.7.2


Which revision are you using?  (hg identify)
fbbc8c80bee2+ tip

Please provide any additional information below.

My simple-minded local fix is:

diff --git a/src/cmd/go/main.go b/src/cmd/go/main.go
--- a/src/cmd/go/main.go
+++ b/src/cmd/go/main.go
@@ -292,6 +292,7 @@
 func run(cmdargs ...interface{}) {
    cmdline := stringList(cmdargs...)
    cmd := exec.Command(cmdline[0], cmdline[1:]...)
+   cmd.Stdin = os.Stdin
    cmd.Stdout = os.Stdout
    cmd.Stderr = os.Stderr
    if err := cmd.Run(); err != nil {

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions