This issue occurs when your GOROOT and/or you GOTOOLDIR and/or your GOVERSION environment indicates a lower version than the one defined in you .mod
file.
To check, run go env
in the terminal within vscode:
# in my own case:
go env
...
GOROOT="/home/me/sdk/go1.18.1"
...
GOTOOLDIR="/home/me/sdk/go1.18.1/pkg/tool/linux_amd64"
...
GOVERSION="go1.18.1"
...
where my .mod
indicates go 1.19
, so go mod tidy
prints the error.
To change your current go version in vscode:
CRTL+P
>
and enter go:choose go environment
or click on the go version on the status bar

then choose the right one, for me go1.19.1.
VScode ask you to reload Windows

but even if you click to reload, the go environement variables are not updated! The only way I found is to close VSCode and to REOpen it, that'it.
By doing so, VSCode setup the go environment variables to the one you've choosen to make your development.
Hope this can help