After upgrading to Go 1.25 (specifically 1.25.1) when I run go test -cover I get this message:
go: no such tool "covdata"
The command exits with status 1.
It seems this does not happen with 1.24 — the version I upgraded from. How do I fix this?
It's probably a bug with the Go toolchain, somehow related to auto-switching the Go version.
Run go env. If you have GOTOOLCHAIN=auto, replace it with a specific version. This fix was suggested by trym-moeller in issue #75031:
It can be noted that manually running
go env -w GOTOOLCHAIN=go1.25.0+autofixed a similar problem for me.
What this does can be found here: https://go.dev/doc/toolchain
The default
GOTOOLCHAINsetting isauto, which enables the toolchain switching described earlier. The alternate form<name>+autosets the default toolchain to use before deciding whether to switch further. For exampleGOTOOLCHAIN=go1.21.3+autodirects the go command to begin its decision with a default of using Go 1.21.3 but still use a newer toolchain if directed bygoandtoolchainlines [in the go.mod file].
NOTE:
Setting a specific toolchain at the env level affects how the go command runs, i.e. it prefers the specific toolchain version in all your repositories. If you must compile some projects with an older version of Go, then be careful.
You can force a specific version on a per-repository basis by setting the env each time you run the command:
GOTOOLCHAIN=go1.25.0+auto go test -cover ./...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With