2.7 Editor Setup: VS Code with gopls, GoLand
Right, let’s get your editor sorted. This isn’t just about typing code; it’s about creating a feedback loop so tight you’ll feel like the compiler is whispering its secrets directly into your ear. We’re going to set up two of the best options: the free, utterly dominant VS Code, and the paid, Go-native powerhouse, GoLand. Both are excellent. Your choice here is between a brilliantly customized Swiss Army knife and a purpose-built scalpel.
The Indispensable gopls
Before we touch an editor, you need to understand the engine that makes both of them purr: gopls, the Go Language Server. A language server is a smart, running process that understands your codebase intimately. It doesn’t just look at the file you’re editing; it analyzes your entire module, all your dependencies, and the Go spec itself to provide you with deep intelligence: pinpoint-accurate autocompletion, find all references, smart refactoring, and showing you your dumb type errors before you even save.
The Go team basically said, “Writing this smartness into every editor plugin is a nightmare, let’s do it once and do it right.” Hence, gopls. It’s the brain. Your editor is just the fancy UI.
Installing it is a one-liner. Crack open your terminal and run:
go install golang.org/x/tools/gopls@latest
This fetches the latest version and slaps the binary into your $GOPATH/bin (which, if you followed the installation instructions, is already on your PATH). This is the only piece of infrastructure both editors need. Now, onto the UI.
VS Code: The Community Standard
VS Code is the go-to for a reason. It’s free, incredibly extensible, and the Go support is first-class. Fire it up, head to the Extensions marketplace (Ctrl+Shift+X), and search for the official “Go” extension published by Google. Install it.
Here’s the beautiful part: the Go extension automatically expects and uses the gopls binary you just installed. It will also helpfully offer to install a bunch of other useful tools (gofumpt, staticcheck, etc.) when you open a Go file. Say yes. These are the picky but brilliant friends who keep your code clean.
The one “gotcha” you might hit is if you have multiple versions of gopls installed or your PATH isn’t correctly set up inside VS Code. If things feel wonky—weird errors, features not working—check the “GOPLS” output channel in VS Code’s Output panel (Ctrl+Shift+U then select “GOPLS”). It logs the entire conversation between the editor and the language server, and it’s almost always the first place to find the truth.
For settings, I highly recommend pushing these to your settings.json (Ctrl+Shift+P, >Preferences: Open Settings (JSON)) to make things buttery smooth:
{
"go.useLanguageServer": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"[go]": {
"editor.defaultFormatter": "golang.go"
},
"gopls": {
"formatting.gofumpt": true // Optional: for stricter formatting
}
}
This tells VS Code to use gopls for everything, to format your code and organize your imports automatically on save (a lifesaver), and to opt into the excellent, stricter gofumpt formatter.
GoLand: The Power Tool
If you’re willing to pay for JetBrains’ masterpiece, you get an environment where all this is not just integrated but native. GoLand is built around understanding Go. You don’t need to install gopls separately for GoLand; it bundles its own managed version of it, which is generally a good thing as it’s tested against that specific IDE version.
The installation is trivial: download, install, open a Go project. It Just Works™. The out-of-the-box experience is arguably better than VS Code’s because the deep refactoring tools, database integration, and Docker support are all built in, not added via extensions.
The biggest mental shift from VS Code is that GoLand has a different philosophy on saving. It has this concept of a “Power Save Mode” which is off by default, meaning it often performs actions like formatting and import management on the fly, not just when you save. It can feel a bit magical, sometimes a bit intrusive. You can configure all this in Settings > Tools > Actions on Save to match the VS Code behavior if you prefer.
So, which one? Use VS Code. It’s free and phenomenal. If you find yourself living in Go, cursing a minor lag in refactoring, or wanting every possible static analysis tool at your fingertips, then buy GoLand. You’ll know when you’re ready for it. Both, powered by gopls, will make you profoundly more productive than raw-text editing ever could.