1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Gregory Eremin 7fa581aba3 Update docs, compare to normal not-equals null check 2 years ago
LICENSE Update docs, compare to normal not-equals null check 2 years ago
README.md Update docs, compare to normal not-equals null check 2 years ago
isnil.go Initial commit 5 years ago
isnil_test.go Update docs, compare to normal not-equals null check 2 years ago

README.md

isnil

nil check that works for interfaces too. Example code and benchmarks.

Benchmarks:

#
# x != nil
#

# nil pointer
BenchmarkEqNilBasic
BenchmarkEqNilBasic-8           1000000000           0.247 ns/op

# nil interface
BenchmarkEqNilInterface
BenchmarkEqNilInterface-8       1000000000           0.247 ns/op


#
# IsNil(x)
#

# nil pointer
BenchmarkIsNilBasic
BenchmarkIsNilBasic-8           274689241            4.37 ns/op

# (*struct{})(nil)
BenchmarkIsNilInterface
BenchmarkIsNilInterface-8       277561260            4.26 ns/op

# nil
BenchmarkIsNilNil
BenchmarkIsNilNil-8             803470719            1.48 ns/op