Some checks are pending
docker-build-cometbft / vars (push) Waiting to run
docker-build-cometbft / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-cometbft / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-cometbft / merge-images (push) Blocked by required conditions
docker-build-e2e-node / vars (push) Waiting to run
docker-build-e2e-node / build-images (amd64, ubuntu-24.04) (push) Blocked by required conditions
docker-build-e2e-node / build-images (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
docker-build-e2e-node / merge-images (push) Blocked by required conditions
29 lines
765 B
Go
29 lines
765 B
Go
package types
|
|
|
|
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
|
|
}
|
|
}
|
|
|
|
// 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
|
|
}
|
|
}
|