From b11c4701c36b1bde91793d8a4ee39fe9aaa298f3 Mon Sep 17 00:00:00 2001 From: Derek McQuay Date: Tue, 15 Nov 2016 21:28:01 -0800 Subject: [PATCH] added ngo flag and default worker value (NumCpu) --- check.go | 3 +-- main.go | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/check.go b/check.go index cdc22f5..1586436 100644 --- a/check.go +++ b/check.go @@ -94,8 +94,7 @@ func check(files []string) chan error { results := []<-chan error{} - workers := 32 - for w := 0; w < workers; w++ { + for w := 0; w < *ngo; w++ { results = append(results, compute(jobs)) } diff --git a/main.go b/main.go index c261dd5..6bd0464 100644 --- a/main.go +++ b/main.go @@ -9,10 +9,12 @@ import ( "fmt" "io" "os" + "runtime" ) var algo = flag.String("a", "sha1", "algorithm to use") var mode = flag.Bool("c", false, "check") +var ngo = flag.Int("n", runtime.NumCPU(), "number of goroutines") func main() { flag.Parse()