Skip to content

Commit

Permalink
better documentation INil and INotNil
Browse files Browse the repository at this point in the history
  • Loading branch information
lainio committed Feb 10, 2024
1 parent fd0a95f commit 41cda29
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions assert/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ func Nil[T any](p *T, a ...any) {

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

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

0 comments on commit 41cda29

Please sign in to comment.