summaryrefslogtreecommitdiff
path: root/workers.go
diff options
context:
space:
mode:
Diffstat (limited to 'workers.go')
-rw-r--r--workers.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/workers.go b/workers.go
index 535e50c..43e398d 100644
--- a/workers.go
+++ b/workers.go
@@ -54,12 +54,7 @@ func workers(startURL url.URL, maxConcurrency, maxURLs int) {
// Convert URLs to Packets. In the
// process, bump up the depth by 1.
- var ps []Packet
-
- for _, u := range batch {
- newPacket := Packet{u, p.depth + 1}
- ps = append(ps, newPacket)
- }
+ ps := convertToPackets(batch, p.depth+1)
select {
case <-ctx.Done():
@@ -110,3 +105,16 @@ loop:
cancel()
wg.Wait()
}
+
+// convertToPackets converts the batch of URLs to a slice of Packet
+// structs, configuring each one with the given depth.
+func convertToPackets(batch []url.URL, depth int) []Packet {
+ var ps []Packet
+
+ for _, u := range batch {
+ newPacket := Packet{u, depth}
+ ps = append(ps, newPacket)
+ }
+
+ return ps
+}