Go version is not the latest

I am using the API Server template for Go. I have a requirement of using the math/rand/v2 package which is only available from Go version 1.22+ however the Go version I have currently with the template is 1.21. How to upgrade to the latest Go version? Is there a way we can specify a specific version of Go we want to be in the system environment using the dev.nix config?

Also checked the Nix os package repository and it supports the version of Go (1.22.6). In the nix config adding pkgs.go should download the latest version provided in the repository I supppose.

The go package showed in NixOS packages is on channel 24.05, the default channel is stable-23.11 on project IDX.

Go to .idx/dev.nix file, change the channel from channel = "stable-23.11"; to channel = "stable-24.05";. And then the version 1.22.6 should be installed.

1 Like