Skip to content

proposal: bufio: Add finalizer to Scanner that warns if .Err not called #51299

@earthboundkid

Description

@earthboundkid

It is unfortunately common for users to incorrectly use Scanner without calling .Err(). (In particular, I've seen it in three different social media posts recently.) We can't change the API, but we can add a runtime.Finalizer that will print a warning to stderr if a Scanner gets garbage collected with Scanner.scanCalled and Scanner.done true but not (new field I would add) Scanner.errCalled.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions