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: allow 'go mod vendor' to omit nested modules in the same repo #33789

Open
mkeeler opened this issue Aug 22, 2019 · 1 comment

Comments

@mkeeler
Copy link

commented Aug 22, 2019

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

$ go version
go version go1.12.9 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/mkeeler/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mkeeler/.go"
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="/Users/mkeeler/Code/repos/consul/master/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/dc/5dk846911dbdkmjk4bj47hhm0000gn/T/go-build297831786=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. git clone https://github.com/hashicorp/consul
  2. go mod vendor

What did you expect to see?

I didn't expect vendor/modules.txt to contain the nested modules within it nor having those nested modules be vendored into the top level vendor folder.

What did you see instead?

Nested submodules are vendored.

We currently get around this by postprocessing the modules.txt and the vendor directory. I realize that nested modules might not be a great idea (it has caused me a number of headaches) however for code living in the same repo the current go mod vendor behavior of vendoring our own code doesn't make much sense to me. Is this intended behavior or just something that isn't protected against.

@bcmills

This comment has been minimized.

Copy link
Member

commented Aug 22, 2019

Is this intended behavior or just something that isn't protected against.

At the moment, this is working as designed: go mod vendor doesn't know (or particularly care) about the overall repo structure — it just knows where the main module is and vendors in the dependencies of the main module wherever they are found.

Omitting same-repo dependencies is one of the use-cases I had in mind for partial vendoring (#30240).

@bcmills bcmills changed the title cmd/go: go mod vendor vendors nested modules in the same repo cmd/go: allow 'go mod vendor' to omit nested modules in the same repo Aug 22, 2019

@bcmills bcmills added this to the Unplanned milestone Aug 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.