@@ -9,24 +9,25 @@ import "fmt"
9
9
10
10
// That checks whether cond is true, and if not, records the error. That panics
11
11
// if the error is nil.
12
- func That (cond bool , err error ) * state {
13
- return new (state ).That (cond , err )
12
+ func That (cond bool , err error ) * State {
13
+ return new (State ).That (cond , err )
14
14
}
15
15
16
16
// Thatf checks whether cond is true, and if not, creates an error from format
17
17
// and args, then records it.
18
- func Thatf (cond bool , format string , args ... any ) * state {
19
- return new (state ).Thatf (cond , format , args ... )
18
+ func Thatf (cond bool , format string , args ... any ) * State {
19
+ return new (State ).Thatf (cond , format , args ... )
20
20
}
21
21
22
- // state holds the errors of the failed conditions.
23
- type state struct {
22
+ // State holds the errors of the failed conditions. It is exported only for the
23
+ // purpose of documentation, do not use it directly.
24
+ type State struct {
24
25
errs []error
25
26
}
26
27
27
28
// That checks whether cond is true, and if not, records the error. That panics
28
29
// if the error is nil.
29
- func (s * state ) That (cond bool , err error ) * state {
30
+ func (s * State ) That (cond bool , err error ) * State {
30
31
if err == nil {
31
32
panic ("check: a nil error is provided" )
32
33
}
@@ -38,17 +39,17 @@ func (s *state) That(cond bool, err error) *state {
38
39
39
40
// Thatf checks whether cond is true, and if not, creates an error from format
40
41
// and args, then records it.
41
- func (s * state ) Thatf (cond bool , format string , args ... any ) * state {
42
+ func (s * State ) Thatf (cond bool , format string , args ... any ) * State {
42
43
return s .That (cond , fmt .Errorf (format , args ... ))
43
44
}
44
45
45
46
// FirstError returns the error of the first failed condition.
46
- func (s * state ) FirstError () error {
47
+ func (s * State ) FirstError () error {
47
48
if len (s .errs ) > 0 {
48
49
return s .errs [0 ]
49
50
}
50
51
return nil
51
52
}
52
53
53
54
// AllErrors returns the errors of all failed conditions.
54
- func (s * state ) AllErrors () []error { return s .errs }
55
+ func (s * State ) AllErrors () []error { return s .errs }
0 commit comments