Standard library / bufio
bufio.Reader.Reset()
Discards buffered data and switches to a new source; unread bytes from the previous source are lost to this reader. Expected stdout: 'z\n'.
Formal Syntax & Structure
go syntaxgo
func (b *Reader) Reset(r io.Reader)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| r | io.Reader | Source reader. |
Working Example
Example Snippetgo
package main
import ( "bufio" "fmt" "strings")
func main() { r := bufio.NewReader(strings.NewReader("abc")) r.Peek(1) r.Reset(strings.NewReader("z")) c, _ := r.ReadByte() fmt.Println(string(c))}