Standard library / strings

strings.Reader

Read-only string reader; Len reports unread bytes and Size original size. ReadAt does not change the cursor; Seek changes position. Reset replaces input; UnreadByte/UnreadRune have last-read constraints. Expected stdout: 'b 1 3\n'.

Formal Syntax & Structure

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

Working Example

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