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
| Name | Type | Description |
|---|---|---|
| offset | int64 | Signed seek displacement. |
| whence | int | Seek 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)}