Skip to content

Commit 41cda29

Browse files
committed
better documentation INil and INotNil
1 parent fd0a95f commit 41cda29

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

assert/assert.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ func Nil[T any](p *T, a ...any) {
303303

304304
// INil asserts that the interface value IS nil. If it is it panics/errors
305305
// (default Asserter) with the given message.
306+
//
307+
// Note, use this only for real interface types. Go's interface's has two values
308+
// so this won't work e.g. slices! Read more information about interface type.
309+
//
310+
// https://go.dev/doc/faq#nil_error
306311
func INil(i any, a ...any) {
307312
if i != nil {
308313
defMsg := assertionMsg + ": interface should be nil"
@@ -312,6 +317,11 @@ func INil(i any, a ...any) {
312317

313318
// INotNil asserts that the interface value is NOT nil. If it is it
314319
// panics/errors (default Asserter) with the given message.
320+
//
321+
// Note, use this only for real interface types. Go's interface's has two values
322+
// so this won't work e.g. slices! Read more information about interface type.
323+
//
324+
// https://go.dev/doc/faq#nil_error
315325
func INotNil(i any, a ...any) {
316326
if i == nil {
317327
defMsg := assertionMsg + ": interface shouldn't be nil"

0 commit comments

Comments
 (0)