Standard library / bytes

bytes.Reader.Reset()

Replaces input and resets the reader state to the beginning. Expected stdout: '2 2\n'.

Formal Syntax & Structure

go syntaxgo
func (r *Reader) Reset(b []byte)

Parameters & Attributes

NameTypeDescription
b[]byteReplacement input; resets reader position.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt")
func main() {  r := bytes.NewReader([]byte("aé"))  r.ReadByte()  r.Reset([]byte("go"))  fmt.Println(r.Len(), r.Size())}
Go Reference