Proposal Details
Currently go mod vendor copies all files in a package except:
- files whose name ends with
_test.go
- files named
go.mod and go.sum
- files whose names ends with
.go and contain a go:build ignore constraint
This means that other random files are copied into the vendored directory. For example, the vendored golang.org/x/sys/unix in the main repo includes mkall.sh, mkerrors.sh, and README.md. There is no reason to vendor those files.
I propose that we change go mod vendor to only copy files that go build recognizes. This is files that end with .go, .c, .cxx, .swig, and so forth. Making this change would also require go mod vendor to look for go:embed directives and copy over all files that they mention (for example, the vendored files in GOROOT/src/cmd/vendor/github.com/google/pprof/internal/driver/html).
Proposal Details
Currently
go mod vendorcopies all files in a package except:_test.gogo.modandgo.sum.goand contain ago:build ignoreconstraintThis means that other random files are copied into the vendored directory. For example, the vendored golang.org/x/sys/unix in the main repo includes
mkall.sh,mkerrors.sh, andREADME.md. There is no reason to vendor those files.I propose that we change
go mod vendorto only copy files thatgo buildrecognizes. This is files that end with.go,.c,.cxx,.swig, and so forth. Making this change would also requirego mod vendorto look forgo:embeddirectives and copy over all files that they mention (for example, the vendored files inGOROOT/src/cmd/vendor/github.com/google/pprof/internal/driver/html).