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: replace directive causes unexpected changes to module sums and vendored packages #40119

Closed
jtlisi opened this issue Jul 8, 2020 · 1 comment

Comments

@jtlisi
Copy link

jtlisi commented Jul 8, 2020

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.

@jtlisi jtlisi changed the title replace directive causes unexpected changes to module sums and vendored packages cmd/go: replace directive causes unexpected changes to module sums and vendored packages Jul 8, 2020
@jtlisi
Copy link
Author

jtlisi commented Jul 8, 2020

I think I may be reporting a duplicate of #29182

@jtlisi jtlisi closed this as completed Jul 8, 2020
@golang golang locked and limited conversation to collaborators Jul 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants