SectionReader in Go

Posted by GoDoc
Public (Editable by Users)

SectionReader implements Read, Seek, and ReadAt on a section of an underlying ReaderAt.

Go
Edit
package main

import (
	"io"
	"log"
	"os"
	"strings"
)

func main() {
	r := strings.NewReader("some io.Reader stream to be read\n")
	s := io.NewSectionReader(r, 5, 17)

	if _, err := io.Copy(os.Stdout, s); err != nil {
		log.Fatal(err)
	}
}