## VSCode setup for Go developers

##### 2021-03-16
vscode vscodium go golang

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:

{
"[go]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"[go.mod]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"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 :

{
"go.buildOnSave": "off",
"go.coverOnSingleTest": true,
"go.coverOnSingleTestFile": true,
"go.lintFlags": ["--fast"],
"go.lintTool": "golangci-lint"
}


Third, you can tweak some git related stuff:

{
"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:

{
"editor.rulers": [120]
}


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

{
"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.

{
"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.

#### Changes in Go implementation of the new protobuf and gRPC

##### Differences between APIv1 and APIv2 implementation of protocol buffers and gRPC in Golang
Go Golang protobuf gRPC vscode