There are a few options as described in the testing flags docs:
go clean -testcache
: expires all test results-count=1
That said, changes in your code or test code will invalidate the cached test results (there's extended logic when using local files or environment variables as well), so you should not need to invalidate the test cache manually.
In Go11, I couldn't disable cache using GOCACHE
with modules, I used -count=1
instead:
go test -count=1
Prior to Go11:
GOCACHE=off go test
Or, clean test cache and run test again:
go clean -testcache && go test
There's also GOCACHE=off
mentioned here.
The way that I fixed this (I'm using Visual Studio Code on macOS):
Code > Preferences > Settings
Click ...
on the right hand side of the settings page
Click Open settings.json
Either:
Add the following snippet to your settings.json file
"go.testEnvVars": {
"GOCACHE": "off"
}
go.testEnvVars
to include the following: "GOCACHE": "off"
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