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: improve build list errors related to replace and exclude directives #35039

Open
jayconrod opened this issue Oct 21, 2019 · 1 comment

Comments

@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented Oct 21, 2019

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

$ go version
go version go1.13.3 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"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/jayconrod/go"
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-build825323019=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

# Create a test module that requires x/tools (or any other module)
cat >use.go <<EOF
package use

import _ "golang.org/x/tools/go/packages"
EOF

go mod init example.com/m
go get -d golang.org/x/tools

# Exclude the version of x/tools we're using. There is no later version.
cp go.mod go.mod~
go mod edit -exclude golang.org/x/tools@$(go list -m -json golang.org/x/tools | jq -r .Version)
go list -m all
# see errors below

# Replace the version with something that doesn't exist instead.
cp go.mod~ go.mod
go mod edit -replace golang.org/x/tools@$(go list -m -json golang.org/x/tools | jq -r .Version) golang.org/x/tools@v1.0.0-doesnotexist
go list -m all
# see errors below

What did you expect to see?

When we can't load a module version that was either replaced or excluded, we should print the file and line number in go.mod where the directive came from.

What did you see instead?

For an exclude directive, we print parens after the main module. It seems like a version would go here, but the main module is the only module where exclude directives are applied, and it never has a version, so these should be left out. The excluded module and version should use an @ instead of parens, consistent with other error messages.

go: example.com/m() depends on excluded golang.org/x/tools(v0.0.0-20191018212557-ed542cd5b28a) with no newer version available

For a replace directive, we don't mention the fact that the module was replaced at all.

go: golang.org/x/tools@v0.0.0-20191018212557-ed542cd5b28a: reading golang.org/x/tools/go.mod at revision v1.0.0: unknown revision v1.0.0
@jayconrod jayconrod added this to the Backlog milestone Oct 21, 2019
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Oct 21, 2019

For a replace directive, we don't mention the fact that the module was replaced at all.

#34256 is closely related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.