Standard library / io

io.SectionReader.Seek()

Moves the section-relative cursor using SeekStart, SeekCurrent or SeekEnd; negative resulting offsets are invalid. Expected stdout: '1 <nil>\n'.

Formal Syntax & Structure

go syntaxgo
func (s *SectionReader) Seek(offset int64, whence int) (int64, error)

Parameters & Attributes

NameTypeDescription
offsetint64Signed seek displacement.
whenceintSeek origin, one of the io.Seek constants.

Return Value

(int64, error)

Moves the section-relative cursor using SeekStart, SeekCurrent or SeekEnd; negative resulting offsets are invalid.

Working Example

Example Snippetgo
package main
import (  "fmt"  "io"  "strings")
func main() {  s := io.NewSectionReader(strings.NewReader("abcd"), 1, 2)  n, e := s.Seek(-1, io.SeekEnd)  fmt.Println(n, e)}
Go Reference