1
1
mirror of https://github.com/wader/fq.git synced 2024-12-18 02:41:44 +03:00
fq/internal/ioextra/ioextra.go
Mattias Wadman 970465996c Init
2021-09-12 13:08:42 +02:00

27 lines
472 B
Go

package ioextra
import (
"errors"
"io"
)
func SeekerEnd(s io.Seeker) (int64, error) {
cPos, err := s.Seek(0, io.SeekCurrent)
if err != nil {
return 0, err
}
epos, err := s.Seek(0, io.SeekEnd)
if err != nil {
return 0, err
}
if _, err := s.Seek(cPos, io.SeekStart); err != nil {
return 0, err
}
return epos, nil
}
type NopSeeker struct{ io.Reader }
func (r *NopSeeker) Seek(offset int64, whence int) (int64, error) { return 0, errors.New("nopseek") }