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.

I figured out 2 ways, to do this:

  1. For the sake of simplicity. 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.
  2. Use the latest version of gopls and have a toggle to switch between

1. Virtual 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/sdk/gotip/bin"
    2export GOPATH="$HOME/go"
    3export PATH="$HOME/sdk/gotip/bin:$PATH:$HOME/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. (Optional) Uninstall golang that you have installed using the official repositories.

    Note: If you run gotip download to update to the latest development version, it will fail, if no stable go version is found. You might want to keep the go stable version.

  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.

2. Host Machine #

  1. You should have go installed on your machine.
  2. Install gotip.
    1go install golang.org/dl/gotip@latest
    
  3. Install the latest version of go using gotip download.
    1# This will take some time depending on your computer.
    2gotip download
    
  4. 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
    
  5. Build and install gopls from source.
    1cd tools/gopls
    2gotip install .
    
  6. Now when you want to use the development version you can just set the path of gotip before the go stable path.
    1# For gopls to pickup the deveploment version before the stable version.
    2export PATH="$HOME/sdk/gotip/bin:$PATH"
    

Final Thoughts #

The first 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.

The second setup will allow you to have a toggle switch between the latest version and the stable version on your host machine.

Happy Goding!