Using Latest Unreleased (Development) Version

Note: This holds for future “versions” of Go, and not just version 1.27.0. gotip will get the latest commit from the git repo and builds Go, this means that you will have the latest “version” of Go based on the most recent commit.

I wanted to use Go version 1.27.0, before the official release. I also, wanted to keep using 1.26.X on my host machine.

I can install the gotip tool, and use it download the latest development version of Go. Then, I can use gotip like the go command to build, run and install.I also wanted to have an LSP in my editor, either helix or zed.

For the sake of simplicity1. I will keep my host machine unaltered and use a virtual machine to install gotip, then gopls, and then zed server to use it from the host machine.

Steps #

  1. Spin up any linux distribution you like.
    • You need to install SSH, and UFW (If you want to enable firewall).
  2. Install the golang version provided by the official repositories.
  3. Install gotip.
    1go install golang.org/dl/gotip@latest
    
  4. Update the .bashrc or whatever shell config that you are using, to set GOBIN, GOPATH.
    1export GOBIN="/home/arch/sdk/gotip/bin/"
    2export PATH="/home/arch/sdk/gotip/bin:$PATH:/home/arch/go/bin"
    
  5. Install the latest version of go using gotip download.
    1# This will take some time depending on your computer.
    2gotip download
    
  6. Uninstall golang that you have installed using the official repositories.
  7. Clone the golang/tools to build and install gopls.
    1# You can also clone from the github mirror
    2git clone https://go.googlesource.com/tools.git
    
  8. Build and install gopls from source.
    1cd tools/gopls
    2gotip install .
    

You can now install Zed server, or use ssh + tmux to write code using helix for example.

Zed Server #

Follow the official guide to install Zed server on the virtual machine.

Why Not Build gopls and Use It? #

We can build gopls with gotip on the host machine, and that will help us have support for Go development version and previous versions of Go. But that works in theory, because gopls will try to download the toolchain when GOTOOLCHAIN is set to auto, and since the development version of Go is yet unreleased, gopls will fail and will not be able to download the toolchain.

Final Thoughts #

This setup will sandbox the latest unrealesed version of Go in a virtual machine, and have the stable version of Go on your host machine. You can still write stable go code on your host machine, and unstable on the virtual machine.

Using Zed client on your host machine to access the Zed server on the virtual machine will make your coding experience as smooth as coding on the host machine.


  1. Mixing Go development version that is not yet released with Go versions that are released, might cause some problems. ↩︎