Standard library / io

io.ReadSeeker

Combines read and seek for random repositioning with sequential reads. Expected stdout: 'bc\n'.

Formal Syntax & Structure

go syntaxgo
type ReadSeeker interface {  Reader  Seeker}

Working Example

Example Snippetgo
package main
import (  "fmt"  "io"  "strings")
func main() {  var r io.ReadSeeker = strings.NewReader("abc")  r.Seek(1, io.SeekStart)  b, _ := io.ReadAll(r)  fmt.Println(string(b))}
Go Reference