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

go get fetches transitive dependencies of unit tests #43896

Closed
codesome opened this issue Jan 25, 2021 · 3 comments
Closed

go get fetches transitive dependencies of unit tests #43896

codesome opened this issue Jan 25, 2021 · 3 comments

Comments

@codesome
Copy link

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

$ go version
go version go1.15.2 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/ganesh/.cache/go-build"
GOENV="/home/ganesh/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/ganesh/go/pkg/mod"
GONOPROXY="github.com/codesome"
GONOSUMDB="github.com/codesome"
GOOS="linux"
GOPATH="/home/ganesh/go"
GOPRIVATE="github.com/codesome"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/ganesh/goroot"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/ganesh/goroot/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/ganesh/go/src/github.com/cortexproject/cortex/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build045883173=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Tried to upgrade package using go get github.com/prometheus/prometheus@master

What did you expect to see?

go get to not consider the unit test files of the dependency for fetching transitive dependencies.

What did you see instead?

go get fetching transitive dependencies for unit tests while at the end the unit test files are never vendored.

Sometimes those unit test dependencies have tendancy to cause issues like this

go: finding module for package k8s.io/api/settings/v1alpha1
github.com/cortexproject/cortex/pkg/api imports
	github.com/prometheus/prometheus/config tested by
	github.com/prometheus/prometheus/config.test imports # <-- the culprit
	github.com/prometheus/prometheus/discovery/kubernetes imports
	k8s.io/client-go/kubernetes imports
	k8s.io/client-go/kubernetes/typed/settings/v1alpha1 imports
	k8s.io/api/settings/v1alpha1: module k8s.io/api@latest found (v0.20.2), but does not contain package k8s.io/api/settings/v1alpha1
@codesome
Copy link
Author

Closing this since it looks like we have some use case. But ideally would have seen those individual use cases (like go test all) to check and fetch transitive test dependencies on-demand instead of always. replace directives to the rescue for now.

@bcmills
Copy link
Contributor

bcmills commented Jan 26, 2021

This was part of the motivation for https://tip.golang.org/doc/go1.16#all-pattern, and for #36460 (work ongoing).

@golang golang locked and limited conversation to collaborators Jan 26, 2022
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

4 participants