-
Notifications
You must be signed in to change notification settings - Fork 0
/
seeker.go
46 lines (38 loc) · 810 Bytes
/
seeker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package mock
import (
"log"
)
func NewSeeker() *seeker {
return &seeker{log: log.Fatal}
}
type seeker struct {
offset int64
whence int
returnOffset interface{}
returnErr error
log func(v ...interface{})
}
func (s *seeker) Seek(offset int64, whence int) (int64, error) {
s.offset = offset
s.whence = whence
if s.returnOffset != nil {
offset = s.returnOffset.(int64)
}
return offset, s.returnErr
}
func (s seeker) SeekOffset() int64 {
return s.offset
}
func (s seeker) SeekWhence() int {
return s.whence
}
func (s *seeker) SeekShouldReturn(offset interface{}, err error) {
if offset != nil {
if _, ok := offset.(int64); !ok {
s.log("method SeekShouldReturn expects 'offset' to be int64 or nil")
return
}
}
s.returnOffset = offset
s.returnErr = err
}