According to the docs:
Context returns a context that is canceled just before Cleanup-registered functions are called.
Verified with a small test:
func TestCleanup(t *testing.T) {
t.Cleanup(func() {
t.Log(t.Context().Err())
})
}
This prints context canceled.
It would be nice if the linter would not report issues when contexts are created within Cleanup functions.
Thanks for the linter though - very handy on Go 1.24!
According to the docs:
Verified with a small test:
This prints
context canceled.It would be nice if the linter would not report issues when contexts are created within Cleanup functions.
Thanks for the linter though - very handy on Go 1.24!