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

Comments

Projects
None yet
2 participants
@ianlancetaylor
Copy link
Contributor

commented May 25, 2018

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 this to the Go1.11 milestone May 25, 2018

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor Author

commented May 25, 2018

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

This comment has been minimized.

Copy link

commented May 25, 2018

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

@gopherbot gopherbot closed this in c1d9d1f May 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.