mirror of https://github.com/uber-go/multierr.git
Currently, appending a non-nil error to a multierror always copies the underlying slice, since there may be multiple goroutines appending to the same multierr,
```go
merr := multierr.Append(errors.New("initial"), errors.New("multierr"))
go func() {
err1 = multierr.Append(merr, errors.New("1"))
[..]
}()
go func() {
err2 = multierr.Append(merr, errors.New("2"))
[..]
}()
```
However, the common use case is a standard for loop:
```go
var merr error
for _, v := range values {
merr = multierr.Append(merr, processValue(v))
}
return merr
```
Since there is only a single resulting slice, we don't need to create a full copy on every `Append`. Instead, we track whether we have modified the underlying slice from `Append` already using an atomic boolean, and only create a copy if the underlying slice has been modified.
|
||
|---|---|---|
| scripts | ||
| .gitignore | ||
| .travis.yml | ||
| CHANGELOG.md | ||
| LICENSE.txt | ||
| Makefile | ||
| README.md | ||
| benchmarks_test.go | ||
| error.go | ||
| error_test.go | ||
| glide.lock | ||
| glide.yaml | ||
README.md
multierr

multierr allows combining one or more Go errors together.
Installation
go get -u go.uber.org/multierr
Status
Beta
Released under the MIT License.