Skip to content

Commit 5cc1710

Browse files
committed
docs & refactoring
1 parent 08168e4 commit 5cc1710

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

assert/assert.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ func MNotEmpty[M ~map[T]U, T comparable, U any](obj M, a ...any) {
851851
}
852852

853853
func doNamed(not, tname, got string, a []any) {
854-
not = x.Whom(not == assertionNot, " not ", "")
854+
not = x.Whom(not == assertionNot, " not ", " ")
855855
defMsg := assertionMsg + ": " + tname + " should" + not + "be " + got
856856
current().reportAssertionFault(1, defMsg, a)
857857
}
@@ -965,15 +965,15 @@ func doNotZero[T Number](val T, a []any) {
965965
// packages. And, yes, we have tested it. This is fastest way to make it without
966966
// locks HERE. Only the setting the index is secured with the mutex.
967967
//
968-
// NOTE that since our TLS [asserterMap] we still continue to use indexing.
968+
// NOTE that since our GLS [asserterMap] we still continue to use indexing.
969969
func current() (curAsserter asserter) {
970-
tlsID := goid()
970+
glsID := goid()
971971
asserterMap.Rx(func(m map[int]asserter) {
972-
aster, found := m[tlsID]
972+
aster, found := m[glsID]
973973
if found {
974974
curAsserter = aster
975975
} else {
976-
// use pkg lvl asserter if asserter is not set
976+
// use pkg lvl asserter if asserter is not set for gorounine.
977977
curAsserter = defAsserter[def]
978978
}
979979
})
@@ -1015,11 +1015,12 @@ func SetDefault(i defInd) (old defInd) {
10151015
return
10161016
}
10171017

1018-
// SetAsserter set asserter index for the current thread (Tread Local
1019-
// Storage). That allows us to have multiple different asserter in use in the
1020-
// same app running. Let's say that in some function and its sub-functions want
1021-
// to return plain error messages instead of the panic asserts, they can use
1022-
// following:
1018+
// SetAsserter set asserter for the current GLS (Gorounine Local Storage). That
1019+
// allows us to have multiple different [asserter] in use in the same process.
1020+
//
1021+
// Let's say that in some function you want to return plain error messages
1022+
// instead of the panic asserts, you can use following in the top-level
1023+
// function:
10231024
//
10241025
// defer assert.SetAsserter(assert.Plain)()
10251026
func SetAsserter(i defInd) func() {

0 commit comments

Comments
 (0)