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: prune non-source files in 'go mod vendor' #33261

ialidzhikov opened this issue Jul 24, 2019 · 1 comment


Copy link

commented Jul 24, 2019

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

$ go version
go version go1.12.7 darwin/amd64

Does this issue reproduce with the latest release?

I would say that the issue is kind of enhancement or feature request rather than a bug. golang/dep has an option to prune non-go files under vendor with a config like:

  go-tests = true
  unused-packages = true
  non-go = true

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

go env Output
$ go env

What did you do?

# The go mod way:

$ mkdir gomod-example
$ cd gomod-example
$ go mod init


package main

import (


func main() {
	j := []byte(`{"name": "John", "age": 30}`)
	y, err := yaml.JSONToYAML(j)
	if err != nil {
		fmt.Printf("err: %v\n", err)
	/* Output:
	name: John
	age: 30
	j2, err := yaml.YAMLToJSON(y)
	if err != nil {
		fmt.Printf("err: %v\n", err)
	/* Output:
$ go mod vendor
$ go mod tidy
$ ls -a vendor/
./  ../  .gitignore  .travis.yml  LICENSE  fields.go  yaml.go  yaml_go110.go

Ensure that non-go files as .gitignore, .travis.yml and others are added under vendor/ and currently there is no way to clean them.

On the other hand golang/dep with non-go = true option:

$ mkdir -p $GOPATH/src/
$ cd $GOPATH/src/
$ dep init
$ dep ensure -v
$ ls -a vendor/
./  ../  LICENSE  fields.go  yaml.go

What did you expect to see?

What did you see instead?


This comment has been minimized.

Copy link

commented Jul 25, 2019

We already filter out test sources, testdata directories, and // +build ignore files (#31088).

Go generally eschews configuration flags, but perhaps we should filter out other non-source-code files by default. (We do presumably need to retain some sources for cgo-enabled builds, such as assembly files and .h and .c files, but perhaps we can identify a specific set that needs to be retained and prune out the rest.)

CC @jayconrod

@bcmills bcmills changed the title cmd/go: Add option to prune non-go files cmd/go: prune non-source files in 'go mod vendor' Jul 25, 2019

@bcmills bcmills added this to the Unplanned milestone Jul 25, 2019

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