For you who have been working intensively for developing NodeJs backend apps must be familiar with NVM (Node Version Manager), the tool that manages different version of NodeJs, so you can easily switch back and forth between them. This also what I need when working with Golang project.
After searching and trying, I found GVM (Golang version Manager).
At the beginning, it is kinda trivial for me to setup such an integration with VSCode using GVM, because I think it'll be easy as usual, you just have to install the golang extension and voila it's done.
Turns out it's not like that...
You have to manually setup the configuration because GVM manages the Golang binary itself on the specific folder on
$HOME/.gvm, not at the actual place such as
/usr/local/bin or similar (you got it unix people!).
After some findings and consulting with stackoverflow, I can set the binary for specific Golang version through the settings.json, which actually dissapointing because I was expected that thing can be done automatically (First Class GVM please!).
GVM is so easy to install, just go to the repository and follows the instructions
then you have to make sure the go version you want is already installed with this command.
The command above shows the installed golang version in my computer, the default version is currently pointed at 1.19.1
If you are at the beginning for GVM, just go install by following this section or doing some command executions like below.
$ gvm listall ~> this will show all available go version to instal $ gvm install go1.19.1 ~> this will install that version
For You who using ARM based CPU, not all versions are available. You must find out what version is supported by crawling at the go.dev download page. (*-arm64)
Then open you VSCode user settings via
<command> + P and type
or depending on your platform:
Because I want to set golang version to global, you can choose a workspace or folder settings if wish a different version according to the project you work on.
then set this config, according to what golang version you want to use.
After that, you'll found the vscode confirm the configuration.
If this is the first time you setup the config for that golang version, the golang extension will also install some tools like
Then you're good to go, have fun!