Skip to content

cmd/go: list and download may read go.mod unnecessarily #36812

@jayconrod

Description

@jayconrod

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

$ go version
go version go1.14beta1 darwin/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=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jayconrod/Library/Caches/go-build"
GOENV="/Users/jayconrod/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/jayconrod/Code/repro/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/go/installed"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/go/installed/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/jayconrod/Code/test/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rq/x0692kqj6ml8cvrhcqh5bswc008xj1/T/go-build200463196=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Run go list -m or go mod download in a directory with a malformed go.mod file. The commands are run with arguments that should not require information about the main module or the build list, so it shouldn't actually be necessary to read go.mod.

go list -m -versions golang.org/x/mod
go mod download golang.org/x/[email protected]
-- go.mod --
ʕ◔ϖ◔ʔ

What did you expect to see?

Both commands should succeed.

What did you see instead?

Both commands fail with an error like the one below:

go: errors parsing go.mod:
/Users/jayconrod/Code/test/go.mod:1: unknown directive: ʕ◔ϖ◔ʔ

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsFixThe path to resolution is known, but the work has not been done.modules

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions