-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen.go
42 lines (31 loc) · 772 Bytes
/
gen.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
package github.com/tyoung3/sw
// import "fmt"
import "sync"
import "strconv"
var version = "v0.28.1"
/*
Gen sends 'nbr' integers, beginning with 'start', incremented
by 'inc'; arguments 1, 2, and 3 respectively over port 0.
#####Examples
(Gen will send:
1 2 3 4 5 6 7
(Gen "-i" "9" "2" "3") will send:
2 5 8 11 14 17 20 23 26
(Gen "-i" "3" "17") will send:
17 18 19
(Gen "-i" "4" "-2" "-1") will send:
-2 -3 -4 -5
*/
func Gen(wg *sync.WaitGroup, arg []string, c chan interface{}) {
defer wg.Done()
defer close(c)
//fmt.Println(arg[0], " swbase.Gen", arg[1], arg[2], arg[3])
nbr, _ := strconv.Atoi(arg[1])
start, _ := strconv.Atoi(arg[2])
inc, _ := strconv.Atoi(arg[3])
ip := start
for n := 0; n < nbr; n++ {
c <- ip
ip += inc
}
}