Passed
Pull Request — master (#52)
by Stefano
02:59
created

producer.*DictionaryProducer.Produce   A

Complexity

Conditions 4

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 11
nop 0
dl 0
loc 18
rs 9.85
c 0
b 0
f 0
1
package producer
2
3
import (
4
	"github.com/stefanoj3/dirstalk/pkg/scan"
5
)
6
7
func NewDictionaryProducer(
0 ignored issues
show
introduced by
exported function NewDictionaryProducer should have comment or be unexported
Loading history...
8
	methods []string,
9
	dictionary []string,
10
	depth int,
11
) *DictionaryProducer {
12
	return &DictionaryProducer{
13
		methods:    methods,
14
		dictionary: dictionary,
15
		depth:      depth,
16
	}
17
18
}
19
20
type DictionaryProducer struct {
0 ignored issues
show
introduced by
exported type DictionaryProducer should have comment or be unexported
Loading history...
21
	methods    []string
22
	dictionary []string
23
	depth      int
24
}
25
26
func (p *DictionaryProducer) Produce() <-chan scan.Target {
0 ignored issues
show
introduced by
exported method DictionaryProducer.Produce should have comment or be unexported
Loading history...
27
	targets := make(chan scan.Target, 10)
28
29
	go func() {
30
		defer close(targets)
31
32
		for _, entry := range p.dictionary {
33
			for _, method := range p.methods {
34
				targets <- scan.Target{
35
					Path:   entry,
36
					Method: method,
37
					Depth:  p.depth,
38
				}
39
			}
40
		}
41
	}()
42
43
	return targets
44
}
45