Published 2025-11-02.
Time to read: 1 minutes.
golang collection.
Installation
Test the installed version:
$ go version go version go1.24.2 linux/amd64
Install the Go extension for Visual Studio Code:
$ code --install-extension golang.Go
Install the Delve debugger:
- the Command Palette CTRL-SHIFT-P
- Type
Go: Install/Update Tools - 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:
"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:
"[go]": {
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.defaultFormatter": "golang.go"
},
The above also defines the default formatter to use for Go source.