1
0
mirror of https://github.com/fluencelabs/tendermint synced 2025-06-28 20:21:47 +00:00
Files
.circleci
.github
DOCKER
abci
behaviour
benchmarks
blockchain
cmd
config
consensus
crypto
docs
evidence
libs
autofile
bech32
cli
clist
common
LICENSE
async.go
async_test.go
bit_array.go
bit_array_test.go
bytes.go
bytes_test.go
byteslice.go
cmap.go
cmap_test.go
errors.go
errors_test.go
int.go
int_test.go
kvpair.go
math.go
net.go
net_test.go
nil.go
os.go
random.go
random_test.go
service.go
service_test.go
string.go
string_test.go
tempfile.go
tempfile_test.go
throttle_timer.go
throttle_timer_test.go
types.pb.go
types.proto
typespb_test.go
events
fail
flowrate
log
pubsub
test
.editorconfig
.gitignore
CHANGELOG.md
README.md
test.sh
lite
mempool
mock
networks
node
p2p
privval
proxy
rpc
scripts
state
store
test
tools
types
version
.editorconfig
.gitignore
.golangci.yml
CHANGELOG.md
CHANGELOG_PENDING.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
Makefile
PHILOSOPHY.md
README.md
ROADMAP.md
SECURITY.md
UPGRADING.md
Vagrantfile
appveyor.yml
codecov.yml
docker-compose.yml
go.mod
go.sum
tendermint/libs/common/nil.go

30 lines
763 B
Go
Raw Normal View History

2018-04-02 01:46:24 -07:00
package common
import "reflect"
// Go lacks a simple and safe way to see if something is a typed nil.
// See:
// - https://dave.cheney.net/2017/08/09/typed-nils-in-go-2
// - https://groups.google.com/forum/#!topic/golang-nuts/wnH302gBa4I/discussion
// - https://github.com/golang/go/issues/21538
func IsTypedNil(o interface{}) bool {
rv := reflect.ValueOf(o)
switch rv.Kind() {
case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.Slice:
return rv.IsNil()
default:
return false
}
}
2018-04-05 03:12:21 -07:00
// Returns true if it has zero length.
func IsEmpty(o interface{}) bool {
rv := reflect.ValueOf(o)
switch rv.Kind() {
case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice, reflect.String:
return rv.Len() == 0
default:
return false
}
}