vscode

Helpful tip for Golang (GOPLS) and VSCode.

If you have been programming with golang in VSCode for a while, you are well aware of the difficulties facing IntelliSense/IDE/Language Server. Otherwise, you live in absolute denial.

You may have been tweaking things, renaming a file here or two, adding a function and soon you will find, no matter what you try, VSCode just won't seem to recognize the new code or even refuse to compile. When it gets like this, I would normally Close the Folder I am working out of and reopen it. If that failed to help, you were left with no choice but just close VSCode all together - sometimes all instances. Both are slow - but more detrimentally - incredibly interruptive.

A while ago, they released a VSCode golang extension update that gave us the ability to try and fix this without all that extra fanfare. It is incredibly helpful to restart the GOPLS language server manually when encountering these issues as it usually resolves things or at least exposes the real part of your code having issues. To help maintain your sanity, I recommend assigning this to a key binding.

restartgoplskeybind.png