log/slog: documentation passes nil contexts, which is discouraged #61219
Labels
Documentation
NeedsFix
The path to resolution is known, but the work has not been done.
release-blocker
Milestone
The documentation of the slog package passes nil contexts, for example:
However, the context package discourages this:
slog internally turns nils into context.Background when calling methods on slog.Handler, which is probably good for resilience, but probably isn't something users should rely on.
In particular, such calls will currently trigger Staticcheck's SA1012 and I'm not sure slog warrants an exception.
I see from golang/exp@f0f767c that this is intentional, so this issue might be contentious. However, I'm not sure the "make them easier to write" argument is as important now, considering there are helpers for pre-defined log levels that don't take context arguments, and it would be unfortunate for the standard library to ignore its own rules.
/cc @jba
The text was updated successfully, but these errors were encountered: