Standard library / bytes

bytes.Reader

Read-only reader over a byte slice, with the same cursor, ReadAt, seeking and unread operations as strings.Reader. Avoid modifying the backing slice while it is read. Expected stdout: 'b 1 3\n'.

Formal Syntax & Structure

go syntaxgo
type Reader struct { /* unexported fields */ }

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt"  "io")
func main() {  r := bytes.NewReader([]byte("abc"))  r.Seek(1, io.SeekStart)  v, _ := r.ReadByte()  fmt.Println(string(v), r.Len(), r.Size())}
Go Reference