Skip to content

bufio: make zero value of Reader useful #45374

@dsnet

Description

@dsnet

Consider the following code pattern:

var br bufio.Reader
for _, r := range readers {
    br.Reset(r)
    ... // make use of br
}

Currently, this pattern results in an infinite loop since the internal buffer of bufio.Reader is empty (resulting in no progress being made). The bufio.Reader.Reset method should initialize the internal buffer with defaultBufSize if it is empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions