Skip to content

Replace context.Background() → t.Context() #3532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jandubois
Copy link
Member

@jandubois jandubois commented May 12, 2025

To quiet down "usetesting" linter.

@jandubois
Copy link
Member Author

I guess this is an argument to switch to Go 1.24: the t.Context() doesn't exist in Go 1.23, but using context.Background() in the test with 1.24 throws a linter error.

@jandubois jandubois marked this pull request as draft May 12, 2025 06:54
@afbjorklund
Copy link
Member

afbjorklund commented May 12, 2025

but using context.Background() in the test with 1.24 throws a linter error.

The linter says that it will disable itself if you run it with an older version?

https://golangci-lint.run/usage/linters/#usetesting

So I guess the entire sub-linter should be removed, until the go version is bumped

i.e. context-background: false

@jandubois
Copy link
Member Author

So I guess the entire sub-linter should be removed, until the go version is bumped

i.e. context-background: false

Makes sense to me; we just need to remember to enable it again when we bump the Go version...

@afbjorklund
Copy link
Member

afbjorklund commented May 12, 2025

I think there were three of them (for go1.24), but not sure if we ran into the others

Templating the linter config sounds like overkill to me, maybe a reminder comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants