A Reader implements the [io.Reader], [io.ReaderAt], [io.WriterTo], [io.Seeker], [io.ByteScanner], and [io.RuneScanner] interfaces by reading from a byte slice. Unlike a [Buffer], a Reader is read-only and supports seeking. The zero value for Reader operates like a Reader of an empty slice.

Hierarchy

  • Reader

Methods

  • Len returns the number of bytes of the unread portion of the slice.

    Returns number

  • Read implements the [io.Reader] interface.

    Parameters

    • b: string | number[]

    Returns number

  • ReadAt implements the [io.ReaderAt] interface.

    Parameters

    • b: string | number[]
    • off: number

    Returns number

  • ReadByte implements the [io.ByteReader] interface.

    Returns number

  • ReadRune implements the [io.RuneReader] interface.

    Returns [number, number]

  • Reset resets the [Reader] to be reading from b.

    Parameters

    • b: string | number[]

    Returns void

  • Seek implements the [io.Seeker] interface.

    Parameters

    • offset: number
    • whence: number

    Returns number

  • Size returns the original length of the underlying byte slice. Size is the number of bytes available for reading via [Reader.ReadAt]. The result is unaffected by any method calls except [Reader.Reset].

    Returns number

  • UnreadByte complements [Reader.ReadByte] in implementing the [io.ByteScanner] interface.

    Returns void

  • UnreadRune complements [Reader.ReadRune] in implementing the [io.RuneScanner] interface.

    Returns void

  • WriteTo implements the [io.WriterTo] interface.

    Parameters

    Returns number

Generated using TypeDoc