DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

go mod, updating to latest versions, and gvm

#go

So, I installed Golang using apt (inside WSL Ubuntu Linux); created a project outside GOROOT with go mod init, then want to update to the latest Go version (1.15.5).

The easiest way to do this (as far as I have experimented), is using gvm. (Similarly, Python => pyenv; Node.js => nvm; Ruby => rbenv; Java => SDKman.)

zsh < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
# or bash < <(...)
Enter fullscreen mode Exit fullscreen mode

Then, edit the ./go.mod

go 1.15.5
Enter fullscreen mode Exit fullscreen mode

I think, knowing this is important, when you are using go mod, because go version will then be fixed inside go.mod.

Actually, VSCode itself can also choose go version, but much less flexible.

Top comments (0)