According to lot of online polls, Visual Studio Code is the most popular IDE among Go developers. You can start Go development immediately after installing Go extension for VSCode, but some tuning may make your life easier. First of all, you may want to format the source code and reorganize imports automatically on each file save or code paste. In order to do so, put the following JSON snippet in your settings.json:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
{
  "[go]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    }
  },
  "[go.mod]": {
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
    }
  },
  "editor.find.addExtraSpaceOnTop": false,
  "editor.formatOnPaste": true,
  "editor.formatOnSave": true,
  "files.autoSave": "onFocusChange",
  "files.insertFinalNewline": true,
  "files.trimTrailingWhitespace": true,
  "go.autocompleteUnimportedPackages": true
}

Second, you may want to configure whether to do test coverage on test run and whether to do build on save. I prefer not to build on save and do the coverage on test run. I also appreciate the help of linters and prefer the most comprehensive one, golangci-lint :

1
2
3
4
5
6
7
{
  "go.buildOnSave": "off",
  "go.coverOnSingleTest": true,
  "go.coverOnSingleTestFile": true,
  "go.lintFlags": ["--fast"],
  "go.lintTool": "golangci-lint"
}

Third, you can tweak some git related stuff:

1
2
3
4
5
{
  "diffEditor.ignoreTrimWhitespace": true,
  "git.autofetch": true,
  "git.enableSmartCommit": true
}

Fourth, you may want to set ruler to 120 characters, which is recommended line length for writing Go code:

1
2
3
{
  "editor.rulers": [120]
}

Finally, if you want your VSCode to look even nicer, you can use the following cosmetic settings:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "breadcrumbs.enabled": true,
  "editor.cursorBlinking": "phase",
  "editor.fontFamily": "'JetBrainsMono Nerd Font'",
  "editor.fontLigatures": true,
  "editor.fontSize": 14,
  "editor.letterSpacing": 0.4,
  "editor.smoothScrolling": true,
  "terminal.integrated.fontSize": 14
}

As you can see, my favorite font at the moment is JetBrainsMono Nerd Font . Nerd Fonts is a collection of popular programming fonts patched by lot of glyphs (icons). These fonts are not useful just for VSCode, but you can also use them in your terminal. I would also recommend Night Owl and Material Icon themes.

It may be opinionated, but I also prefer to disable the minimap and use blank file on VSCode start.

1
2
3
4
{
  "editor.minimap.enabled": false,
  "workbench.startupEditor": "newUntitledFile"
}

At the end of this article I also want to mention that I actually use VSCodium , which is open source version of VSCode and has no tracking.