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: 'go vet' causes all dependencies of the child module to be added to the parent module #38900

Closed
LastPossum opened this issue May 6, 2020 · 1 comment

Comments

@LastPossum
Copy link

LastPossum commented May 6, 2020

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

$ go version
go version go1.13.5 darwin/amd64

Does this issue reproduce with the latest release?

Yes for 1.14.2

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/egartman/Library/Caches/go-build"
GOENV="/Users/egartman/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GOOS="darwin"
GOPATH="/Users/egartman/go"
GOPRIVATE=""
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/egartman/go/src/github.com/lastpossum/reproduce/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/mv/gfk793qd08b1kj0qcxt5cf_40000gn/T/go-build266849048=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. clone this
  2. ensure that go.sum is empty
  3. go vet client/child_test.go

What did you expect to see?

Output of go vet.
Source code is not changed.

What did you see instead?

All client module dependencies are included in go.mod top level

@bcmills bcmills changed the title go vet causes all dependencies of the child module to be added to the parent module cmd/go: 'go vet' causes all dependencies of the child module to be added to the parent module May 6, 2020
@bcmills bcmills added the modules label May 6, 2020
@bcmills
Copy link
Contributor

bcmills commented May 6, 2020

Per go doc packages:

As a special case, if the package list is a list of .go files from a single directory, the command is applied to a single synthesized package made up of exactly those files, ignoring any build constraints in those files and ignoring any other files in the directory.

When you write go vet client/child_test.go, you are asking the go command to run vet on a synthetic package consisting of only client/chield_test.go, not the package ./client.

Then go vet ends up resolving the dependencies of that synthetic package (because they are not already in your dependency graph), and records the versions used in your go.mod file so that the command you just ran will produce the same results if you run it again.

As far as I can tell this is all working as designed, but CC @jayconrod @matloob in case they disagree.

@bcmills bcmills closed this as completed May 6, 2020
@golang golang locked and limited conversation to collaborators May 6, 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

3 participants