Skip to content

False positive on context usage within Cleanup funcs #4

@pkwarren

Description

@pkwarren

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!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions