diff --git a/internal/errd/wrap.go b/internal/errd/wrap.go index c80d0a65..3ca36c46 100644 --- a/internal/errd/wrap.go +++ b/internal/errd/wrap.go @@ -2,13 +2,17 @@ package errd import ( "fmt" + "io" ) // Wrap wraps err with fmt.Errorf if err is non nil. // Intended for use with defer and a named error return. // Inspired by https://github.com/golang/go/issues/32676. +// +// io.EOF is never wrapped because the Go convention requires +// callers to test for EOF using ==, not errors.Is. func Wrap(err *error, f string, v ...any) { - if *err != nil { + if *err != nil && *err != io.EOF { *err = fmt.Errorf(f+": %w", append(v, *err)...) } }