From 7c9e29a7680fb70223b128dcae12d09e042c8833 Mon Sep 17 00:00:00 2001 From: Ryan Balfanz <133278+RyanBalfanz@users.noreply.github.com> Date: Thu, 21 Oct 2021 22:16:21 -0700 Subject: [PATCH] reduce scope of err variable https://github.com/uber-go/guide/blob/master/style.md#reduce-scope-of-variables --- batch.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/batch.go b/batch.go index 14d70fc..13ae5e1 100644 --- a/batch.go +++ b/batch.go @@ -21,12 +21,13 @@ func All(count, batchSize int, eachFn BatchFunc) error { // passed end, so set to end item end = count - 1 } - err := eachFn(i, end) - if err == Abort { - return nil - } - if err != nil { - return err + if err := eachFn(i, end); err != nil { + if err == Abort { + return nil + } + if err != nil { + return err + } } i = end + 1 }