Skip to content

cmd/go: 'go mod vendor' removes requirement on replaced module #30857

@songjiayang

Description

@songjiayang

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

$ go version
go version go1.12 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

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/xxxx/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH=""
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/project/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/zb/p5mbxpss5j19k76c9kd3wy5jxfrpjg/T/go-build045757485=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I run go mod vendor to package all my code dependence, the go.mod had been changed.

Before change:

module my-module

require (
	my.module.com/common/appconfig v0.0.0
	my.module.com/common/config v0.0.0
)

replace (
	my.module.com/common/appconfig => ../common/appconfig
	my.module.com/common/config => ../common/config
)

After change:

module my-module

require (
	my.module.com/common/appconfig v0.0.0
)

replace (
	my.module.com/common/appconfig => ../common/appconfig
	my.module.com/common/config => ../common/config
)

It auto delete my.module.com/config at require field, then i build with -mod=vendor , Go 1.12 is ok , but Go 1.11.2 with error cannot find module for path my.module.com/common/config exit 1

In this case, my appconfig module had required config yet, So I want to known this's a bug for Go 1.12 or a new feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.modules

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions