Skip to content

cmd/go, x/tools/go/packages: handle os-specific command length limitations #54800

@findleyr

Description

@findleyr

While working on #54509, I encountered a surprising bug in go/packages: by renaming "golang.org/x/tools/internal/lsp" to "golang.org/x/tools/gopls/internal/lsp", it appears I pushed a go list invocation within our test setup past a windows limit for command line length:
https://storage.googleapis.com/go-build-log/0d6a7f9d/windows-amd64-2016_664249aa.log

(@adonovan found a reference citing a 32kb limit, which appears to be exceeded by the collective set of package directories in that test output).

Shortening our test module path resolved the failure (for now), but I expect we'll hit it again soon as we add more test data. Furthermore, our test data is certainly smaller than even medium-sized repositories, so it seems likely that our users are hitting this limit in practice.

Ideally, go/packages.Load should handle these limitations within the go list driver, perhaps by breaking up large queries.

CC @bcmills

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions