Skip to content

log/slog: fix HandlersOptions.ReplaceAttr documentation when attribute is discarded #60870

@powerman

Description

@powerman

Documentation for latest (v0.0.0-20230522175609-2e198f4a06a1) version of HandlersOptions.ReplaceAttr says:

If ReplaceAttr returns an Attr with Key == "", the attribute is discarded.

This is counter-intuitive (because Handler.Handle docs discard zero attribute instead), prevent returning group attrs with empty key to embed group, and didn't match actual behaviour of current implementation (which is correct: it discards zero Attr and handles Attr with empty Key but non-zero Value).

Looks like docs should be fixed to match current implementation.
(Maybe golang.org/x/exp/slog docs needs similar fix.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions