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: incorrect message when replace target fails to resolve to correct module #34256

Open
myitcv opened this issue Sep 12, 2019 · 3 comments

Comments

@myitcv
Copy link
Member

commented Sep 12, 2019

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

$ go version
go version devel +396d625330 Thu Sep 12 07:45:53 2019 +0000 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=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOENV="/home/myitcv/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/myitcv/gos"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build854839250=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Consider the following testscript test:

go mod tidy

-- tools.go --
// +build tools

package tools

import (
        _ "golang.org/x/tools/go/analysis"
        _ "golang.org/x/tools/gopls"
)

-- go.mod --
module example.com/hello

go 1.13

require (
        golang.org/x/tools v0.0.0-20190911230505-6bfd74cf029c
        golang.org/x/tools/gopls v0.1.5
)

replace golang.org/x/tools => github.com/myitcvforks/tools v0.0.0-20190911230505-6bfd74cf029c

replace golang.org/x/tools/gopls => github.com/myitcvforks/tools v0.0.0-20190911230505-6bfd74cf029c

What did you expect to see?

An error telling me the replace for golang.org/x/tools/gopls is incorrect because the target of the replace is the module golang.org/x/tools

What did you see instead?

go: github.com/myitcvforks/tools@v0.0.0-20190911230505-6bfd74cf029c: parsing go.mod:
        module declares its path as: golang.org/x/tools
                but was required as: github.com/myitcvforks/tools

cc @bcmills @jayconrod

@bcmills

This comment has been minimized.

Copy link
Member

commented Sep 12, 2019

Somewhat related to #34085, in that we are reporting the replacement path in place of what should be the module it replaces.

@bcmills bcmills added this to the Go1.14 milestone Sep 12, 2019
@myitcv

This comment has been minimized.

Copy link
Member Author

commented Sep 12, 2019

Ah thanks. Feel free to close if you think it's a duplicate. I searched for "required as" hence I didn't spot #34085

@bcmills

This comment has been minimized.

Copy link
Member

commented Sep 12, 2019

I don't think the fix for #34085 will address this case, so it's probably better to keep as a separate issue.

@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.