nilcheck

package
v1.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package nilcheck reports whether an interface value has nothing behind it.

It exists because redis-kit's constructors take redis.UniversalClient rather than *redis.Client. A concrete pointer parameter made "no client" a single state that `== nil` recognised. An interface parameter splits it in two: a nil interface, and a non-nil interface holding a nil pointer -- which is what a caller passes from an unassigned struct field or a constructor that returned early:

var rdb *redis.Client        // never assigned
c := cache.NewCache(rdb, "") // c.client != nil, and every call panics

Every nil check in this module goes through IsNil so that case keeps returning "redis client is nil" instead of dereferencing a nil pointer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNil

func IsNil(v any) bool

IsNil reports whether v is a nil interface or an interface holding a nil pointer, map, slice, channel or function.

A non-pointer value -- a struct implementing the interface directly, as test doubles often do -- is never nil and reports false.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL