Standard library / strings

strings.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(s string)

Parameters & Attributes

NameTypeDescription
sstringReplacement input; resets reader position.

Working Example

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