Problem with GOROOT

I’ve had this problem for a while. I install a new version of Go, let’s say 1.25, and when I run go version, it tells me it’s version 1.23.

Checking GOROOT using go env GOROOT always shows

C:\Users\MyUser\go\pkg\mod\golang.org\toolchain@v0.0.1-go1.21.3.windows-amd64. Even though I clean everything up, it always removes that directory and installs everything by default.

I set GOROOT update using setx GOROOT "C:\Path\To\Go". Is there any way to update this according to the installation?

You should probably check the environment settings for both system and user. In my experience GOROOT can be left unset . It defaults then to the directory where the used Go binary is deployed.

1 Like

Hi, What I did:

  • I uninstalled version 1.25.
  • I deleted the directory and went to my home folder.
  • I downloaded version 1.21, installed it, and then uninstalled it.
  • I checked environment variables and everything, and GOROOT doesn’t appear anywhere.
  • I reinstalled version 1.25.
    This time I didn’t create the Go directory in my home folder, but when I run go version, it still tells me I have version 1.21.
    In the directory where I installed Go (C:\Program Files), there’s a file called version with the value 1.25, but it still reports the same thing.

I did no touch GOROOT so it is clear but i do not why it still sends the same message.

Thanks a lot for your response,

Yamil

Uff….! I solved it. There is some references to version 1.21 in AppData/Roaming/Go. I cleaned up that folder, cleaned environment vars and install version 1.25 again

1 Like