Skip to content

Commit 648367e

Browse files
committed
feat: withJoin 增加 Len 和 ToError
1 parent 23096a3 commit 648367e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

join.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ type ErrorJoin interface {
3737
error
3838
Append(error)
3939
Unwrap() []error
40+
Len() int
41+
ToError() error
4042
}
4143

4244
type withJoin struct {
@@ -95,3 +97,14 @@ func (w *withJoin) Format(s fmt.State, verb rune) {
9597
}
9698
}
9799
}
100+
101+
func (w *withJoin) Len() int {
102+
return len(w.errs)
103+
}
104+
105+
func (w *withJoin) ToError() error {
106+
if len(w.errs) == 0 {
107+
return nil
108+
}
109+
return w
110+
}

0 commit comments

Comments
 (0)