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: package names are printed to stderr instead of stdout on build #10309

Closed
joegrasse opened this issue Apr 1, 2015 · 6 comments
Closed

Comments

@joegrasse
Copy link

When passing the -v flag to the go build command, package names are printed to stderr instead of stdout.

Offending code line.

fmt.Fprintf(os.Stderr, "%s\n", a.p.ImportPath)

@ianlancetaylor ianlancetaylor changed the title package names are printed to stderr instead of stdout on build cmd/go: package names are printed to stderr instead of stdout on build Apr 1, 2015
@ianlancetaylor
Copy link
Contributor

Printing -v output to stderr makes it work well when any errors occur during compilation, or when using -x. Why is this a bug?

@joegrasse
Copy link
Author

I see what you are saying. When compiling multiple packages, if a package has a compilation error you would like to know which package it is for. However, I believe this is already handled, because if you do go build and there is an error you will see the following output.

E:\gowork\src\github.com\joegrasse\passtest>go build
# github.com/joegrasse/passtest
.\passtest.go:26: syntax error: unexpected }

Notice the package name printed once vs the package name printed twice below with the -v flag.

E:\gowork\src\github.com\joegrasse\passtest>go build -v
github.com/joegrasse/passtest
# github.com/joegrasse/passtest
.\passtest.go:26: syntax error: unexpected }

My issue is when there are no "true" errors you still have output to stderr with the -v option. Which in turn leads to issue GoClipse/goclipse#119.

@ianlancetaylor
Copy link
Contributor

I agree that the error message tells you which package failed, but it's still convenient to not have strange interleaving in the output. Plus, -x.

I don't understand why goclipse is passing -v at all. This doesn't seem like a strong reason to change the way the go tool works.

@joegrasse
Copy link
Author

I guess I would ask why -x is sent to stderr as well. Why not stdout for that, since it is information and not errors?

@ianlancetaylor
Copy link
Contributor

OK, forget -x. We can agree that -x and -v should use the same rule.

It's still convenient to not have strange interleaving in the output.

I don't see the fact that goclipse decides to pass -v as a compelling reason to change how the tool behaves, because I don't know a reason why goclipse should do that.

@robpike
Copy link
Contributor

robpike commented Apr 2, 2015

Working as intended. Diagnostic output goes to stderr; that's what stderr is for.

@robpike robpike closed this as completed Apr 2, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants