Go Tooling Setup Basics
10 examples to get you started with gopls & Debugging - 7 basic and 3 intermediate.
Search across all documentation pages
10 examples to get you started with gopls & Debugging - 7 basic and 3 intermediate.
mkdir tooling-demo && cd tooling-demo && go mod init example.com/tooling-demo.$(go env GOPATH)/bin is on your PATH so installed tools are found.go install golang.org/x/tools/gopls@latest
go install github.com/go-delve/delve/cmd/dlv@latest
go install golang.org/x/vuln/cmd/govulncheck@latest
go install honnef.co/go/tools/cmd/staticcheck@latestConfirm the language server and debugger binaries resolve before configuring an editor.
which gopls dlv
gopls version
dlv versiongo install places binaries in GOPATH/bin (often ~/go/bin).gopls by name; a missing PATH entry looks like "language server not found."Related: Go Developer Tooling: LSP, Debugger, and Analyzers - how the pieces fit together
Point gopls at your module root and enable formatting on save in VS Code-style settings.
{
"gopls": {
"ui.semanticTokens": true,
"formatting.gofumpt": true
},
"go.useLanguageServer": true
}go.mod, not a parent directory with unrelated modules.formatting.gofumpt applies stricter formatting than gofmt alone.Related: gopls: Navigation, Refactoring & Diagnostics - editor features powered by gopls
go vet is built in and needs no extra install.
go vet ./...go vet stays useful in quick scripts.Related: staticcheck & golangci-lint in CI - layering analyzers in CI
staticcheck finds correctness and performance issues beyond vet.
staticcheck ./...go install honnef.co/go/tools/cmd/staticcheck@latest.-checks only when you need to disable a specific rule temporarily.Related: staticcheck & golangci-lint in CI - severity and baselines
Check whether known CVEs affect code you actually import.
govulncheck ./...go test so module download is already warm.Related: govulncheck for Dependency Vulnerabilities - triage and CI wiring
Start the debugger on main.go and break at program entry.
# main.go: package main with func main()
dlv debug .Inside the dlv REPL:
(dlv) break main.main
(dlv) continue
(dlv) next
(dlv) print x
dlv debug builds with debug symbols and starts the process under the debugger.continue, next, and step like gdb-style commands.quit ends the session.Related: Debugging with Delve - goroutines and remote attach
Run a bundled linter set with one command.
# install once
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run ./....golangci.yml when you customize enabled linters.Related: staticcheck & golangci-lint in CI - config and adoption
go.work)When developing a library and consumer together, use a workspace file.
go work init ./app ./lib
go work use ./libOpen the directory containing go.work in your editor so gopls resolves cross-module imports.
go.work, local replaces require replace directives in go.mod.go.work for cross-references.Related: Go Developer Tooling: LSP, Debugger, and Analyzers - monorepo tooling model
Run Delve listening on a port so VS Code or GoLand attaches remotely.
dlv debug --headless --listen=:2345 --api-version=2 --accept-multiclient .localhost:2345 with API v2.Related: Debugging with Delve - remote and container attach
Commit a minimal .golangci.yml so laptops and CI share rules.
run:
timeout: 5m
linters:
enable:
- govet
- staticcheck
- ineffassign
- misspell
issues:
max-issues-per-linter: 0
max-same-issues: 0max-issues-per-linter: 0 fails the run on any finding - loosen during migration.govulncheck in a separate CI job for dependency CVEs.Related: gopls & Analysis Tooling Best Practices - editor and CI hygiene
Stack versions: This page was written for Go 1.26.x (Green Tea GC default, go fix modernizers - verify patch at build), chi (latest - verify at build), gin (latest - verify at build), echo (latest - verify at build), google.golang.org/grpc (latest - verify at build), sigs.k8s.io/controller-runtime (latest - verify at build), kubebuilder (latest - verify at build), tinygo (latest - verify board targets at build), wazero (latest - verify at build), and golangci-lint (latest - verify linter set at build).
Reviewed by Chris St. John·Last updated Jul 19, 2026