Go

Go Language Setup

Published 2025-11-02.
Time to read: 1 minutes.

This page is part of the golang collection.

Installation

Install Go.

Test the installed version:

Shell
$ go version
go version go1.24.2 linux/amd64 

Install the Go extension for Visual Studio Code:

Shell
$ code --install-extension golang.Go

Install the Delve debugger:

  1. the Command Palette CTRL-SHIFT-P
  2. Type Go: Install/Update Tools
  3. Select dlv (Delve debugger) from the list and install it

Code Folding

Go is not automatically configured for folding in Visual Studio Code. I use the #region folding for VS Code extension to provide code folding. Add the following to the appropriate Visual Studio Code settings.json:

.vscode/settings.json fragment
"maptz.regionfolder": {
  "[go]": {
    "foldStart": "// #region [NAME]",
    "foldEnd": "// #endregion",
    "foldStartRegex": "//[\\s]*#region",
    "foldEndRegex": "//[\\s]*#endregion"
  }
}

Spaces vs. Tabs

I strongly favor spaces. I only use tabs in Makefiles because that is required. However, the official recommendation for Go is to use tabs.

😈 Fuck that. 😈

I defined a formatting rule in Visual Studio Code to convert tabs to spaces in all files with a .go filetype. The rule lives in %APPDATA%/Code/User/settings.json:

%APPDATA%/Code/User/settings.json
"[go]": {
  "editor.insertSpaces": true,
  "editor.tabSize": 2,
  "editor.defaultFormatter": "golang.go"
},

The above also defines the default formatter to use for Go source.

* indicates a required field.

Please select the following to receive Mike Slinn’s newsletter:

You can unsubscribe at any time by clicking the link in the footer of emails.

Mike Slinn uses Mailchimp as his marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp’s privacy practices.