-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathscanners.go
More file actions
77 lines (60 loc) · 1.15 KB
/
scanners.go
File metadata and controls
77 lines (60 loc) · 1.15 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package mock
import "github.com/src-d/lookout"
type SliceChangeScanner struct {
Changes []*lookout.Change
Error error
ChangeTick chan struct{}
val *lookout.Change
}
func (s *SliceChangeScanner) Next() bool {
if s.Error != nil {
return false
}
if len(s.Changes) == 0 {
s.val = nil
return false
}
s.val, s.Changes = s.Changes[0], s.Changes[1:]
return true
}
func (s *SliceChangeScanner) Err() error {
return s.Error
}
func (s *SliceChangeScanner) Change() *lookout.Change {
if s.ChangeTick != nil {
<-s.ChangeTick
}
return s.val
}
func (s *SliceChangeScanner) Close() error {
return nil
}
type SliceFileScanner struct {
Files []*lookout.File
Error error
FileTick chan struct{}
val *lookout.File
}
func (s *SliceFileScanner) Next() bool {
if s.Error != nil {
return false
}
if len(s.Files) == 0 {
s.val = nil
return false
}
s.val, s.Files = s.Files[0], s.Files[1:]
return true
}
func (s *SliceFileScanner) Err() error {
return s.Error
}
func (s *SliceFileScanner) File() *lookout.File {
if s.FileTick != nil {
<-s.FileTick
}
return s.val
}
func (s *SliceFileScanner) Close() error {
return nil
}