Let’s say you have Go 1.20.1 installed locally, but the project you are working on requires Go 1.22.3.
First, install the additional version of the Go SDK.
VS Code
Set GOROOT
to point to the Go version you need. Add the following to the workspace settings:
"go.goroot": "${env:HOME}/sdk/go1.22.3"
GoLand
Go to Settings → Go → GOROOT and add or select the version you need there.