Skip to content

Commit

Permalink
join error slice
Browse files Browse the repository at this point in the history
  • Loading branch information
camdencheek committed Jan 8, 2024
1 parent 30a99cd commit c6e6d74
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions iter/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ func (m Mapper[T, R]) MapErr(input []T, f func(*T) (R, error)) ([]R, error) {
var (
res = make([]R, len(input))
errMux sync.Mutex
errs error
errs []error
)
Iterator[T](m).ForEachIdx(input, func(i int, t *T) {
var err error
res[i], err = f(t)
if err != nil {
errMux.Lock()
errs = multierror.Join(errs, err)
errs = append(errs, err)
errMux.Unlock()
}
})
return res, errs
return res, multierror.Join(errs...)
}

0 comments on commit c6e6d74

Please sign in to comment.