Duplicate of#67233
Description
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:
[prune]
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 github.com/ialidzhikov/gomod-example
main.go
package main
import (
"fmt"
"github.com/ghodss/yaml"
)
func main() {
j := []byte(`{"name": "John", "age": 30}`)
y, err := yaml.JSONToYAML(j)
if err != nil {
fmt.Printf("err: %v\n", err)
return
}
fmt.Println(string(y))
/* Output:
name: John
age: 30
*/
j2, err := yaml.YAMLToJSON(y)
if err != nil {
fmt.Printf("err: %v\n", err)
return
}
fmt.Println(string(j2))
/* Output:
{"age":30,"name":"John"}
*/
}
$ go mod vendor
$ go mod tidy
$ ls -a vendor/github.com/ghodss/yaml/
./ ../ .gitignore .travis.yml LICENSE README.md 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/github.com/ialidzhikov/dep-example
$ cd $GOPATH/src/github.com/ialidzhikov/dep-example
$ dep init
$ dep ensure -v
$ ls -a vendor/github.com/ghodss/yaml/
./ ../ LICENSE fields.go yaml.go
What did you expect to see?
What did you see instead?
Metadata
Metadata
Assignees
Labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
bcmills commentedon 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
[-]cmd/go: Add option to prune non-go files[/-][+]cmd/go: prune non-source files in 'go mod vendor'[/+]