• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lif0 / pkg / 18429782830

11 Oct 2025 01:05PM UTC coverage: 98.408% (-0.3%) from 98.695%
18429782830

Pull #17

github

web-flow
Merge 9d55396de into 9fe027048
Pull Request #17: Release utils@v1.1.0

22 of 25 new or added lines in 1 file covered. (88.0%)

680 of 691 relevant lines covered (98.41%)

29597.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.0
/utils/errx/multi_error.go
1
package errx
2

3
import (
4
        "bytes"
5
        "fmt"
6
)
7

8
// MultiError is a slice of errors implementing the error interface.
9
type MultiError []error
10

11
// Error formats the contained errors as a bullet point list, preceded by the
12
// total number of errors. Note that this results in a multi-line string.
13
func (errs MultiError) Error() string {
3✔
14
        if len(errs) == 0 {
4✔
15
                return ""
1✔
16
        }
1✔
17
        buf := &bytes.Buffer{}
2✔
18
        fmt.Fprintf(buf, "%d error(s) occurred:", len(errs))
2✔
19
        for _, err := range errs {
6✔
20
                fmt.Fprintf(buf, "\n* %s", err)
4✔
21
        }
4✔
22
        return buf.String()
2✔
23
}
24

25
// Append appends the provided error if it is not nil.
26
func (errs *MultiError) Append(err error) {
4✔
27
        if err != nil {
6✔
28
                *errs = append(*errs, err)
2✔
29
        }
2✔
30
}
31

32
// MaybeUnwrap returns nil if len(errs) is 0. It returns the first and only
33
// contained error as error if len(errs is 1). In all other cases, it returns
34
// the MultiError directly. This is helpful for returning a MultiError in a way
35
// that only uses the MultiError if needed.
36
func (errs MultiError) MaybeUnwrap() error {
3✔
37
        switch len(errs) {
3✔
38
        case 0:
1✔
39
                return nil
1✔
40
        case 1:
1✔
41
                return errs[0]
1✔
42
        default:
1✔
43
                return errs
1✔
44
        }
45
}
46

47
// IsEmpty returns true if MultiError has no errors, otherwise false.
NEW
48
func (errs MultiError) IsEmpty() bool {
×
NEW
49
        return len(errs) == 0
×
NEW
50
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc