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.
|
2 years ago | |
---|---|---|
LICENSE | 2 years ago | |
README.md | 2 years ago | |
isnil.go | 5 years ago | |
isnil_test.go | 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