how to solve "stderr: go mod tidy: go.mod file indicates go 1.17, but maximum supported version is 1.16 ." error?

Viewed 9218

I am getting "Command 'gopls.tidy' failed: Error: err: exit status 1: stderr: go mod tidy: go.mod file indicates go 1.17, but maximum supported version is 1.16 ." error on Visual Studio Code. I can't fix it with go mod tidy and go mod init. How can I solve this?

5 Answers

A simple command in the terminal helped me:

brew upgrade go

GoLang has been updated, I have restarted the project, and everything is working

I deleted go and installed again then problem is solved.

I solved thisby using https://go.dev/doc/manage-install, to change my current version of golang (1.16), and set the version that the project needs, then set my GOROOT and PATH of go, with the new version and then run go mod tidy

This is the error i got:

go mod tidy: go.mod file indicates go 1.18, but maximum supported version is 1.17

My GOROOT was 1.18 but somehow my it seems changed to 1.17 version. I think Goland misguided and in your case it could be VSCode.

Anyway, i changed my GOROOT sdk version to 1.18 and problem solved.

I had the same error in Goland and solved it by restarting the IDE. May also work in Visual Studio.

Related