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 shouldn't log information it was given on the command line #37388

Open
perillo opened this issue Feb 23, 2020 · 6 comments
Open

cmd/go: mod init shouldn't log information it was given on the command line #37388

perillo opened this issue Feb 23, 2020 · 6 comments
Labels
Milestone

Comments

@perillo
Copy link

@perillo perillo commented Feb 23, 2020

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

$ go version
go version go1.14rc1 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/home/manlio/.local/bin"
GOCACHE="/home/manlio/.cache/go-build"
GOENV="/home/manlio/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/manlio/.local/lib/go:/home/manlio/src/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/manlio/sdk/go1.14rc1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/manlio/sdk/go1.14rc1/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/go/t2/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build802837126=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version go1.14rc1 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.14rc1
uname -sr: Linux 5.5.4-arch1-1
/usr/lib/libc.so.6: GNU C Library (GNU libc) stable release version 2.31.
gdb --version: GNU gdb (GDB) 9.1

What did you do?

In an empty directory:

$ go mod init test

What did you expect to see?

The module path of the new module test on stdout.

What did you see instead?

go: creating new go.mod: module test

on stderr.

This kind of output should only be enabled with a -v flag.

By default, go mod init should print the module path on stdout, and a -v flag should be added to implement the current behavior.

@perillo perillo changed the title cmd/go: mod init prints verbose output cmd/go: mod init prints not requested verbose output Feb 23, 2020
@bcmills
Copy link
Member

@bcmills bcmills commented Feb 24, 2020

In principle I agree, provided that the module path was specified explicitly.

However, if the module path was inferred automatically (for example, from the location within GOPATH), we should probably still log something about the inferred path.

CC @matloob @jayconrod

@bcmills bcmills changed the title cmd/go: mod init prints not requested verbose output cmd/go: mod init shouldn't log information it was given on the command line Feb 24, 2020
@bcmills bcmills added this to the Backlog milestone Feb 24, 2020
@bcmills
Copy link
Member

@bcmills bcmills commented Feb 24, 2020

(#35070 (comment) describes another situation where the logging is probably helpful, but the proper fix there is to stop writing the go.mod file in that case.)

@perillo
Copy link
Author

@perillo perillo commented Feb 24, 2020

go mod init do print the inferred path. The problem is that it print it on stderr and with insignificant information like go: creating new go.mod:.

It may log more useful information in case it is converting from an old versioning tool.
If this information is important and should be available without a new -v flag, it could be written on stderr.

However, as I wrote, the module path, alone, should always be printed on stdout, either when the path is inferred or explicitly set by the user.

@perillo
Copy link
Author

@perillo perillo commented Feb 24, 2020

Just to clarify, the reason go mod init should print the module path of the newly created module on stdout is to allow a tool to invoke go mod init and get the module path, for later use.

I'm writing a go-init tool, that initializes a git repository at the user specified path, cd to it and invoke go mod init. It then needs the module path later, and I was forced to invoke go list -m, too.

@bcmills
Copy link
Member

@bcmills bcmills commented Feb 24, 2020

What's wrong with invoking go list -m to determine the module path?

@perillo
Copy link
Author

@perillo perillo commented Feb 24, 2020

Nothing. But I think go mod init should do it, since I'm creating a new module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.