Standard library / bytes
bytes.Reader.UnreadByte()
Moves the byte cursor back one position; fails at the start. Do not assume repeated unreads are portable across io.ByteScanner implementations. Expected stdout: '<nil> 3\n'.
Formal Syntax & Structure
go syntaxgo
func (r *Reader) UnreadByte() errorReturn Value
error
Moves the byte cursor back one position; fails at the start. Do not assume repeated unreads are portable across io.ByteScanner implementations.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt")
func main() { r := bytes.NewReader([]byte("aé")) r.ReadByte() e := r.UnreadByte() fmt.Println(e, r.Len())}