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

mwf opened this issue Aug 14, 2018 · 2 comments


None yet
2 participants
Copy link

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 > /dev/null

What did you expect to see?

I expect to see no output.

What did you see instead?

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

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.


This comment has been minimized.

Copy link

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


This comment has been minimized.

Copy link

commented Aug 14, 2018

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


@mwf mwf closed this Aug 14, 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.