Standard library / io

io.ByteScanner

Extends ByteReader with UnreadByte for one-byte lookahead. Expected stdout: 'a\n'.

Formal Syntax & Structure

go syntaxgo
type ByteScanner interface {  ByteReader  UnreadByte() error}

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt"  "io")
func main() {  var r io.ByteScanner = bytes.NewReader([]byte("a"))  r.ReadByte()  r.UnreadByte()  b, _ := r.ReadByte()  fmt.Println(string(b))}
Go Reference