Skip to content

proposal: bytes: add Buffer.Peek #73794

Open
@icholy

Description

@icholy

Proposal Details

Add a Peek method to bytes.Buffer to avoid unnecessary wrapping when passing a buffer to image.Decode.

package bytes

// Peek returns the next n bytes without advancing the buffer.
// If there are fewer than n bytes in the buffer, it returns error [io.EOF].
// The slice is only valid until the next buffer modification.
func (b *Buffer) Peek(n int) ([]byte, error)

See:

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposal

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions