Standard library / io
io.ReaderAt
Reads at explicit byte offsets without changing a seek cursor. Short reads require an error, and parallel ReadAt calls are allowed. Expected stdout: '2 bc <nil>\n'.
Formal Syntax & Structure
go syntaxgo
type ReaderAt interface { ReadAt(p []byte, off int64) (n int, err error)}Working Example
Example Snippetgo
package main
import ( "fmt" "io" "strings")
func main() { var r io.ReaderAt = strings.NewReader("abc") p := make([]byte, 2) n, e := r.ReadAt(p, 1) fmt.Println(n, string(p), e)}