Skip to content

proposal: cmd/go: vendor: only copy files that the Go build system recognizes #67233

Open
@ianlancetaylor

Description

@ianlancetaylor

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions