Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go build -o /dev/null a.go creates the file "a" #25579

Closed
ianlancetaylor opened this issue May 25, 2018 · 2 comments
Closed

cmd/go: go build -o /dev/null a.go creates the file "a" #25579

ianlancetaylor opened this issue May 25, 2018 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@ianlancetaylor
Copy link
Contributor

On current tip (1ba26a3).

Running go build -o /dev/null hello.go creates the executable hello. go build -o x hello.go works as expected.

> rm ./hello
rm: cannot remove './hello': No such file or directory
> go build -o x ~/hello.go
> ls -l x hello
ls: cannot access 'hello': No such file or directory
-rwxr-x--- 1 iant primarygroup 2651894 May 25 13:58 x*
> rm ./x
> go build -o /dev/null ~/hello.go
> ls -l hello
-rwxr-x--- 1 iant primarygroup 2651894 May 25 13:58 hello*
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label May 25, 2018
@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone May 25, 2018
@ianlancetaylor
Copy link
Contributor Author

This happens with Go 1.10, does not happen with Go 1.9.

It seems to be because runBuild clears cfg.BuildO when it is /dev/null, and then GoFilesPackage sets it back to the base name of the first file on the command line.

@ianlancetaylor ianlancetaylor self-assigned this May 25, 2018
@gopherbot
Copy link

Change https://golang.org/cl/114715 mentions this issue: cmd/go: don't generate output for "go build -o /dev/null x.go"

@golang golang locked and limited conversation to collaborators May 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants