From e2962707f79ab00ad055e09127bb8ef0f2c45b02 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sun, 16 Jun 2019 13:19:08 -0400 Subject: Ran go fmt properly (on everything this time) --- autoutils/batches.go | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'autoutils/batches.go') diff --git a/autoutils/batches.go b/autoutils/batches.go index fb39fc1..7e27473 100644 --- a/autoutils/batches.go +++ b/autoutils/batches.go @@ -20,7 +20,7 @@ along with AutoArt. If not, see . package autoutils import ( - "fmt" + "fmt" ) /* @@ -31,26 +31,27 @@ a message will be printed, starting with progress, and showing how many batches have been completed so far out of the total number of batches. */ const batchSize = 32 -func RunInBatches(number int64, progress string, f func (n int64, errs chan<- error)) error { - nBatches := number / batchSize - errs := make(chan error) - for batch := int64(0); batch <= nBatches; batch++ { - fmt.Println(progress, batch+1, "/", nBatches+1) - thisBatchSize := batchSize - if batch == nBatches { - // Deal with case of last batch - thisBatchSize = int(number - nBatches * batchSize) - } - for task := 0; task < thisBatchSize; task++ { - go f(int64(task) + batchSize * batch, errs) - } - - for completed := 0; completed < thisBatchSize; completed++ { - err := <-errs - if err != nil { - return err - } - } - } - return nil -} \ No newline at end of file + +func RunInBatches(number int64, progress string, f func(n int64, errs chan<- error)) error { + nBatches := number / batchSize + errs := make(chan error) + for batch := int64(0); batch <= nBatches; batch++ { + fmt.Println(progress, batch+1, "/", nBatches+1) + thisBatchSize := batchSize + if batch == nBatches { + // Deal with case of last batch + thisBatchSize = int(number - nBatches*batchSize) + } + for task := 0; task < thisBatchSize; task++ { + go f(int64(task)+batchSize*batch, errs) + } + + for completed := 0; completed < thisBatchSize; completed++ { + err := <-errs + if err != nil { + return err + } + } + } + return nil +} -- cgit v1.2.3