Skip to content

cmd/go: replace directive causes unexpected changes to module sums and vendored packages #40119

@jtlisi

Description

@jtlisi

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

$ go version
go version go1.14.4 darwin/amd64

&&

$ go version
go version go1.14.2 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="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jtlisi/Library/Caches/go-build"
GOENV="/Users/jtlisi/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY="github.com/grafana"
GONOSUMDB="github.com/grafana"
GOOS="darwin"
GOPATH="/Users/jtlisi/go"
GOPRIVATE="github.com/grafana"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/jtlisi/tmp/go_mod_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/kr/2yc18cj500ncq900qws2cvw00000gn/T/go-build659070102=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. Ran go mod tidy & go mod vendor
  2. Added a replace override to my go.mod file with the exact same version/rev as the currently required module.
  3. Ran go mod tidy & go mod vendor

What did you expect to see?

I expected no major diffs and any diff in go.sum that did exist would not trigger a change to a vendored package.

What did you see instead?

  • Extra modules being added to the require statement
  • Significant diff to the go.sum file
  • Changes to vendor-ed packages

I have create a repo here: [https://github.com/jtlisi/go_modules_replace_behaviour]. This repo documents the issue I'm experiencing in the README with copies of the diffs. This repo can also be downloaded and the above steps can be run to replicate the issue.

I'm not sure if this is expected behavior for the replace directive and go mod. If so I would appreciate it if someone could help me understand how I can avoid these large diffs when adding a replace directive that does not feature any changes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions