Skip to content

Commit

Permalink
feat: withJoin 增加 Len 和 ToError
Browse files Browse the repository at this point in the history
  • Loading branch information
ace-zhaoy committed Nov 17, 2024
1 parent 23096a3 commit 648367e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions join.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type ErrorJoin interface {
error
Append(error)
Unwrap() []error
Len() int
ToError() error
}

type withJoin struct {
Expand Down Expand Up @@ -95,3 +97,14 @@ func (w *withJoin) Format(s fmt.State, verb rune) {
}
}
}

func (w *withJoin) Len() int {
return len(w.errs)
}

func (w *withJoin) ToError() error {
if len(w.errs) == 0 {
return nil
}
return w
}

0 comments on commit 648367e

Please sign in to comment.