cover

Go1.18 Beta Experience

sorcererxwβ€’

Go1.18 beta1 has been released, and so far it seems that there are no major issues with using 1.18 in local environments as long as generics are not used in production code. Transitioning to the 1.18 development environment now allows for early exploration of projects related to generics.

However, currently Homebrew does not support Go1.18beta1. The best way to install 1.18 is to use https://github.com/moovweb/gvm (Go Version Manager).

zsh < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)

source ~/zshrc

gvm install go1.18beta1
gvm use go1.18beta1

Okay, now Go1.18beta1 has been installed on your local machine.

go version
> go version go1.18beta1 darwin/amd64

However, when opening the project with vscode, it was found that vscode still cannot parse code containing generics. This is because vscode relies on gopls to parse Go code, so we need to reinstall gopls with the Go1.18 environment.

go install golang.org/x/tools/gopls@latest

In this way, we can use Go1.18 for development normally.