1
1
mirror of https://github.com/wader/fq.git synced 2024-12-18 10:52:44 +03:00
fq/internal/ioextra/ioextra.go

27 lines
472 B
Go
Raw Normal View History

2020-06-08 03:29:51 +03:00
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") }