Skip to content

x/tools/gopls: analyze workspace without opening code editor #75907

@zhdaniel

Description

@zhdaniel

gopls version

golang.org/x/tools/gopls v0.20.0

go env

AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='$USER/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='$USER/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/00/51v9d1hx0cz8r36v_s077_xw0000gn/T/go-build71646679=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='$USER/sandbox/golang-tools/go.mod'
GOMODCACHE='$USER/go/pkg/mod'
GOOS='darwin'
GOPATH='$USER/go'
GOROOT='$USER/local/go'
GOTELEMETRY='local'
GOTELEMETRYDIR='$USER/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='$USER/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.3'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

none

What did you see happen?

none

What did you expect to see?

When opening a large Go project in VS Code, gopls analyzes the project and builds index caches, which consumes a lot of CPU and memory. This often makes the computer very slow or even unusable for other tasks.

I’m wondering if it’s possible to expose this indexing process as a separate command in the gopls CLI, so that I could run it manually during idle times or set it up as a scheduled task. like:

gopls index $WORKSPACE

Editor and settings

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.ToolsThis label describes issues relating to any tools in the x/tools repository.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions