Skip to content

bufio: document SplitFunc corner cases #25472

@yaxum62

Description

@yaxum62

The current document of bufio.SplitFunc does not cover all cases and left few details buried into implementations. Such as:

  1. A Scanner behave differently when a SplitFunc returns token with nil or an empty byte slice. example
  2. A Scanner usually skip advanced bytes when returned token is nil. example

Here I propose few changes to doc, clearly state those behavior. Such as:

  1. If a SplitFunc returns a non-nil error, returned advance and token are ignored.
  2. If a SplitFunc returns a non-nil token, even if it is empty, Scanner will always yield, no matter what error a reader previously returns.
  3. If a SplitFunc returns a nil token with non-zero advance, Scanner will skip those bytes.

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