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 mod vendor should ignore README, CONTRIBUTING and any other non metadata file is part of a subdirectory of the module #27337

Closed
didrocks opened this issue Aug 29, 2018 · 5 comments

Comments

Projects
None yet
5 participants
@didrocks
Copy link

commented Aug 29, 2018

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

go version go1.11 linux/amd64

Does this issue reproduce with the latest release?

go mod vendor has been introduced with 1.11

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/didrocks/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/didrocks/work/golibs:/home/didrocks/work/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build833100184=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I run go mod vendor, experimenting to remove vendor/ directory from my repo, but still using it for building ubuntu packages in our build system which is offline when building.

What did you expect to see/What did you see instead?

I saw a lot of files are filtered like AUTHORS, LICENSE from my go dependencies, also main packages like in cmd/ directories are as well skipped from the copy, which is great.

However, I see that the vendor/ directory ships README.md, CONTRIBUTING.md and a lot of metadata/vcs/build system file .gitignore, .travis.yaml. I don't think those files are a good fit for the vendor directory as this one is generated and not the source of documentation, readme or contributors guide.

I'm happy proposing a PR on gerrit to add README/CONTRIBUTING prefixed files from go mod vendor if there is an agreement here. I'm a little bit unsure about the other ones though, like .gitignore, .travis.yaml as those aren't capitalized and quite extensive as per vcs and such. A good approach may be to skip any files in the root of the copied module directory starting with a "."?

What do you think?

@oiooj oiooj added the modules label Aug 29, 2018

@FiloSottile FiloSottile added this to the Go1.12 milestone Aug 30, 2018

@FiloSottile FiloSottile changed the title Extend metaPrefixes ignore list in go mod vendor to include README and CONTRIBUTING cmd/go: extend metaPrefixes ignore list in go mod vendor to include README and CONTRIBUTING Aug 30, 2018

@didrocks

This comment has been minimized.

Copy link
Author

commented Sep 5, 2018

Is there anything I can do to weigh in and getting a decision? I'm happy to deal with the patch in 2 parts (the README/CONTRIBUTINGS) and a second part for everything starting with . in the root folder of the module, if necessary, to trigger the discussion.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Oct 25, 2018

I'm a little confused about the report, but it sounds like what is being requested is:

  1. Make go mod vendor copy README* and CONTRIBUTING* from modules into vendored copies.
  2. Also make it copy .gitignore and .travis.yaml into vendored copies.

The files that are copied now are the ones that may be legally required to copy the code (basically, copyright notices and supporting files). There is no attempt to make the vendored copy useful in any other way, such as by copying READMEs etc. The assumption is that people who want to look at the code will look at an original copy, not the trimmed copy in a vendor directory.

I think the copy set should be left alone.

@rsc rsc closed this Oct 25, 2018

@didrocks

This comment has been minimized.

Copy link
Author

commented Oct 26, 2018

@rsc: sorry, I may have not been clear enough. We are saying the same thing.

go mod vendor currently includes README*, CONTRIBUTING*, .gitignore and .travis.yaml. I'm proposing to create a PR to ignore those, as I think as you do that they should be trimmed from the vendor directory.

For instance, after running go mod vendor in 1.11.1:

vendor/golang.org/x/sys/unix/README.md
vendor/github.com/inconshreveable/mousetrap/README.md
vendor/github.com/pkg/errors/README.md
vendor/github.com/sirupsen/logrus/README.md
vendor/github.com/spf13/pflag/README.md
vendor/github.com/spf13/cobra/README.md
vendor/github.com/russross/blackfriday/README.md
vendor/gopkg.in/yaml.v2/README.md
$ find vendor/ -name '.gitignore'
vendor/golang.org/x/sys/unix/.gitignore
vendor/github.com/pkg/errors/.gitignore
vendor/github.com/sirupsen/logrus/.gitignore
vendor/github.com/spf13/pflag/.gitignore
vendor/github.com/spf13/cobra/.gitignore
vendor/github.com/russross/blackfriday/.gitignore

As soon as some files like those are in a subdirectory of the module itself, it's getting copied.

Edit: rephrased bug title to better match intent

@didrocks didrocks changed the title cmd/go: extend metaPrefixes ignore list in go mod vendor to include README and CONTRIBUTING cmd/go: go mod vendor should ignore README and CONTRIBUTING Oct 26, 2018

@didrocks didrocks changed the title cmd/go: go mod vendor should ignore README and CONTRIBUTING cmd/go: go mod vendor should ignore README, CONTRIBUTING and any other non metadata file is part of a subdirectory of the module Oct 26, 2018

@alvaroaleman

This comment has been minimized.

Copy link

commented Apr 23, 2019

@rsc @didrocks Was this discussed? IMHO it is pretty pointless to have the dependencies READMEs, .gitignore or CI configs like .travis.yml versioned as part of the vendor/ directory

@didrocks

This comment has been minimized.

Copy link
Author

commented Apr 23, 2019

@alandonovan: I didn't hear more from @rsc or anyone from the Go team on that since my last replied. I'm still happy to implement this as needed, after a ack for the team.

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