mirror of
https://github.com/wader/fq.git
synced 2024-12-18 10:52:44 +03:00
27 lines
472 B
Go
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") }
|