-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (34 loc) · 973 Bytes
/
main.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 main
import (
"fmt"
"github.com/mahdibouaziz/price-calculator/filemanager"
"github.com/mahdibouaziz/price-calculator/prices"
)
func main() {
taxRates := []float64{0, 0.07, 0.1, 0.15}
doneChans := make([]chan bool, len(taxRates))
errorChans := make([]chan error, len(taxRates))
for index, taxRate := range taxRates {
doneChans[index] = make(chan bool)
errorChans[index] = make(chan error)
// cmd := cmdmanager.New()
// priceJob := prices.NewTaxIncludedPriceJob(cmd, taxRate)
fm := filemanager.New("prices.txt", fmt.Sprintf("result_%.0f.json", (taxRate*100)))
priceJob := prices.NewTaxIncludedPriceJob(fm, taxRate)
go priceJob.Process(doneChans[index], errorChans[index])
// err := priceJob.Process()
// if err != nil {
// fmt.Println(err)
// }
}
for index := range taxRates {
select {
case err := <-errorChans[index]:
if err != nil {
fmt.Println(err)
}
case <-doneChans[index]:
fmt.Println("Done")
}
}
}