Who
This warning is produced by the official linter for Go source code - golint. Golint is used as the default linter by the Go extension in Visual Studio Code editor.
Why
To understand the reason why golint showed that warning, we can refer to the official Go documentation related to comments - "Go Doc Comments" (quote):
Every exported (capitalized) name in a program should have a doc comment.
But this indeed can be annoying if you tend to write self-documenting code (i.e. the intention is clear from a name itself etc).
Solution
Besides the already proposed solutions, what you can do is start using the alternative and more advanced golangci-lint which is a Go linters aggregator. It has golint disabled by default, so this annoying warning about missing doc comments will not be triggered. Of course you can turn this warning on if you want by using the related flags (see --exclude strings
and --exclude-use-default
).
The possibility to change the linter is also mentioned on the description page of Go extension:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/CQQH6.png)
How to change lint tool for the Go Extension in VS Code
In order to change lint tool in VS Code perform the following steps.
1) Choose the "Configure Extension Settings" in the Go Extension's management menu:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/z5s01.png)
2) Select "golangci-lint" from the related drop-down list:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/Zic8C.png)
3) To prevent VS Code from freezing as a result of using this powerful linter, add the --fast
flag as described in the "Editor Integration" instructions.
To do that, you need to navigate to the Go Extension configuration page (as in step 1), open the settings.json
file and add the related configuration as shown on the below screenshots:
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/UXqrX.png)
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/vOTvX.png)
NB! Here is a quote from the "golangci-lint" FAQ:
Why running with --fast is slow on the first run?
Because the first run caches type information. All subsequent runs will be fast.
Usually this options is used during development on local machine and compilation was already performed.