Gopls LSP
/install gopls-lsp
gopls LSP
Go language server integration providing comprehensive code intelligence through gopls (the official Go language server).
Capabilities
- Code intelligence: Autocomplete, go-to-definition, find references
- Error detection: Real-time diagnostics for compilation errors and issues
- Refactoring: Rename symbols, extract function, organize imports
- Analysis: Static analysis, code suggestions, unused code detection
- Supported extensions:
.go
Installation
Install gopls using the Go toolchain:
go install golang.org/x/tools/gopls@latest
Important: Make sure $GOPATH/bin (or $HOME/go/bin) is in your PATH.
Verify installation:
gopls version
Usage
The language server runs automatically in LSP-compatible editors. For manual operations:
Format code
gofmt -w file.go
Run linter
go vet ./...
Build and test
go build ./...
go test ./...
Configuration
Create gopls.yaml in your project or workspace for custom settings:
analyses:
unusedparams: true
shadow: true
completeUnimported: true
staticcheck: true
Or configure via environment:
export GOPLS_CONFIG='{"staticcheck": true, "analyses": {"unusedparams": true}}'
Integration Pattern
When editing Go code:
- gopls provides real-time diagnostics in LSP editors
- Run
go fmtorgofmtto format code - Use
go vetfor additional static analysis - Run tests with
go testbefore committing
Common Go Commands
go mod init \x3Cmodule>- Initialize Go modulego mod tidy- Clean up dependenciesgo get \x3Cpackage>- Add dependencygo build- Compile packagesgo run main.go- Run programgo test- Run testsgo vet- Report suspicious constructs
More Information
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install gopls-lsp - 安装完成后,直接呼叫该 Skill 的名称或使用
/gopls-lsp触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Gopls LSP 是什么?
Go language server (gopls) providing code intelligence, refactoring, and analysis for .go files. Use when working with Go code that needs autocomplete, go-to-definition, find references, error detection, or refactoring support. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 1213 次。
如何安装 Gopls LSP?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install gopls-lsp」即可一键安装,无需额外配置。
Gopls LSP 是免费的吗?
是的,Gopls LSP 完全免费(开源免费),可自由下载、安装和使用。
Gopls LSP 支持哪些平台?
Gopls LSP 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Gopls LSP?
由 bowen31337(@bowen31337)开发并维护,当前版本 v1.0.0。