Go Development in VS Code
The Go extension for VS Code (powered by gopls) provides world-class tooling — fast IntelliSense, test runners, debugging, and deep integration with the Go toolchain.
1Setting Up Go in VS Code
Install Go (by Go Team at Google) from the marketplace. On first open of a .go file, it prompts to install the Go tool dependencies — click Install All. This downloads gopls, dlv (debugger), staticcheck, and more.
mkdir myapp && cd myapp go mod init github.com/you/myapp code .
2gopls Features
- Completion with full type information
- Automatic imports — adds missing imports on save
- Rename across modules
- Extract function / variable
- Inlay hints for types and parameter names
- Workspace-wide symbol search
3Running & Testing
Run and debug any func main() with the CodeLens buttons above it. Test files get individual run/debug buttons per test. Ctrl+Shift+P → Go: Test Package runs all tests in the current package with coverage.
4Delve Debugger
The Go extension uses Delve under the hood — the most capable Go debugger. It supports goroutine inspection, viewing the full goroutine stack, evaluating expressions involving goroutines, and following goroutines across context switches.
5staticcheck & golangci-lint
Enable staticcheck in settings for deeper analysis beyond the compiler. For CI, use golangci-lint — its VS Code integration shows lint results inline. Configure it with .golangci.yml in your project root.