@@ -1021,24 +1021,17 @@ func current() (curAsserter asserter) {
1021
1021
return curAsserter
1022
1022
}
1023
1023
1024
- // SetDefault sets the current default [Asserter] for assert pkg. It also
1025
- // returns the previous [Asserter].
1024
+ // SetDefault sets the new default [Asserter] for the assert pkg instance you're
1025
+ // currently using. It also returns the previous [Asserter]. The default
1026
+ // asserter is [Production] that's best for most use cases and packages.
1026
1027
//
1027
- // Note that you should use this in TestMain function, and use [flag] package to
1028
- // set it for the app. For the tests you can set it to panic about every
1029
- // assertion fault, or to throw an error, or/and print the call stack
1030
- // immediately when assert occurs. The err2 package helps you to catch and
1031
- // report all types of the asserts.
1028
+ // Note that for most cases [PushAsserter] is most suitable. [PushAsserter]
1029
+ // allows you to set [Asserter] per goroutine or function, i.e., until you pop
1030
+ // the asserter out, and the assert package uses the current default [Asserter]
1031
+ // set by [SetDefault].
1032
1032
//
1033
- // Note that if you are using tracers you might get two call stacks, so test
1034
- // what's best for your case.
1035
- //
1036
- // Tip. If our own packages (client packages for assert) have lots of parallel
1037
- // testing and race detection, please try to use same [Asserter] for all of them
1038
- // and set [Asserter] only one in TestMain, or in init.
1039
- //
1040
- // func TestMain(m *testing.M) {
1041
- // SetDefault(assert.TestFull)
1033
+ // Note that if you are using tracers you might get overlapping call stacks, so
1034
+ // test what's best for your case.
1042
1035
func SetDefault (i Asserter ) (old Asserter ) {
1043
1036
// pkg lvl lock to allow only one pkg client call this at one of the time
1044
1037
// together with the indexing, i.e we don't need to switch asserter
0 commit comments