It seems that behavior has changed - errors.Join now returns a single error if that error implements Unwrap() []error [1].
This seems contra to the documentation, which says [2]: // Join returns an error that wraps the given errors. And also the definition of "wraps" which doesn't include an error wrapping itself: // If e.Unwrap() returns a non-nil error w or a slice containing w, // then we say that e wraps w. I've also got an example on the playground at [4]. [1] https://cs.opensource.google/go/go/+/refs/tags/go1.25.5:src/errors/join.go;l=32 [2] https://pkg.go.dev/[email protected]#Join [3] https://pkg.go.dev/[email protected]#pkg-overview [4] https://go.dev/play/p/ZWk1dwtQoDe On Saturday, August 2, 2025 at 6:36:04 PM UTC+2 [email protected] wrote: > I've just been bitten by this behavior as well. It's very sad this can't > be changed. I'd argue that the contract of Join() is only to return an > error and that property will be maintained, but I realize this is a moot > argument... > > On Saturday, July 6, 2024 at 4:23:36 PM UTC+2 Ian Lance Taylor wrote: > >> On Sat, Jul 6, 2024 at 7:04 AM Andrei Rusakov <[email protected]> wrote: >> > >> > So, what do you think it makes sense for the function to return a >> wrapped error even if it contains only one error? Wouldn't it be more >> rational in such cases for Join to return that single error? >> >> Perhaps that would have made sense, but we can't make a change like >> that now that errors.Join has its current behavior. >> >> Ian >> > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/75d7a6ef-a53a-4a74-8c6a-199dafb3936fn%40googlegroups.com.
