Skip to content

Commit 5f39d8f

Browse files
committed
docs: export State for pkg.go.dev to render its methods
1 parent 77e6159 commit 5f39d8f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

check.go

+11-10
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,25 @@ import "fmt"
99

1010
// That checks whether cond is true, and if not, records the error. That panics
1111
// 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)
1414
}
1515

1616
// Thatf checks whether cond is true, and if not, creates an error from format
1717
// 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...)
2020
}
2121

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 {
2425
errs []error
2526
}
2627

2728
// That checks whether cond is true, and if not, records the error. That panics
2829
// 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 {
3031
if err == nil {
3132
panic("check: a nil error is provided")
3233
}
@@ -38,17 +39,17 @@ func (s *state) That(cond bool, err error) *state {
3839

3940
// Thatf checks whether cond is true, and if not, creates an error from format
4041
// 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 {
4243
return s.That(cond, fmt.Errorf(format, args...))
4344
}
4445

4546
// FirstError returns the error of the first failed condition.
46-
func (s *state) FirstError() error {
47+
func (s *State) FirstError() error {
4748
if len(s.errs) > 0 {
4849
return s.errs[0]
4950
}
5051
return nil
5152
}
5253

5354
// 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

Comments
 (0)