func main() {
var merr error
for i := range 3 {
merr = errors.Join(fmt.Errorf("%d", i))
}
fmt.Printf("incorrect multi-error: %v\n", merr)
merr = nil
for i := range 3 {
merr = errors.Join(merr, fmt.Errorf("%d", i))
}
fmt.Printf("correct multi-error: %v\n", merr)
}
In the codebase, there are multiple entries (e.g. one, two, three) of wrong
errors.Join
function usage leading to the non-expected results.In the following example one could clearly see the problem:
The output is: