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: 'mod init' writes info message to stderr #26984

Closed
mwf opened this issue Aug 14, 2018 · 2 comments
Closed

cmd/go: 'mod init' writes info message to stderr #26984

mwf opened this issue Aug 14, 2018 · 2 comments

Comments

@mwf
Copy link

mwf commented Aug 14, 2018

What version of Go are you using (go version)?

go version devel +81555cb4f3 Tue Aug 14 09:19:38 2018 +0000 darwin/amd64

Does this issue reproduce with the latest release?

Yes, latest master.

What did you do?

cd `mktemp -d`
go mod init example.com/foo > /dev/null

What did you expect to see?

I expect to see no output.

What did you see instead?

$ go mod init example.com/foo > /dev/null
go: creating new go.mod: module example.com/foo

go mod init writes this message to Stderr.

I would prefer if it wrote to stdout instead, so I could ignore the output in my script.

And I definitely don't want to ignore the stderr - in case of any error occurs.

@mvdan
Copy link
Member

mvdan commented Aug 14, 2018

Using standard error for non-error messages is fine. For example, the log package uses standard error by default.

If you want to ignore output as long as no error happened, simply keep the output somewhere, and only use it if the exit code is non-zero.

@mvdan mvdan changed the title cmd/go: go mod init writes info message to stderr cmd/go: 'mod init' writes info message to stderr Aug 14, 2018
@mwf
Copy link
Author

mwf commented Aug 14, 2018

Thanks, that makes sense.
I just thought it's not an intended behaviour.

Closing.

@mwf mwf closed this as completed Aug 14, 2018
@golang golang locked and limited conversation to collaborators Aug 14, 2019
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

3 participants