Skip to content

Commit a744f45

Browse files
committed
flag & TestMain info for SetDefault documentation
1 parent c6b877a commit a744f45

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

assert/assert.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,16 +731,20 @@ func Default() Asserter {
731731
return defAsserter[def]
732732
}
733733

734-
// SetDefault set the current default asserter for the package. For example, you
735-
// might set it to panic about every assertion fault, and in other cases, throw
736-
// an error, and print the call stack immediately when assert occurs.
734+
// SetDefault set the current default asserter for assert pkg.
735+
//
736+
// Note, that you should use this in TestMain function, and use Flag package to
737+
// set it for the app. For the tests you can set it to panic about every
738+
// assertion fault, or to throw an error, or/and print the call stack
739+
// immediately when assert occurs. The err2 package helps you to catch and
740+
// report all types of the asserts.
737741
//
738742
// Note, that if you are using tracers you might get two call stacks, so test
739743
// what's best for your case.
740744
//
741745
// Tip. If our own packages (client packages for assert) have lots of parallel
742746
// testing and race detection, please try to use same asserter for all of them
743-
// and do it only one in TestMain, or in init.
747+
// and set asserter only one in TestMain, or in init.
744748
//
745749
// func TestMain(m *testing.M) {
746750
// SetDefault(assert.TestFull)

0 commit comments

Comments
 (0)