redis/go-redis · error

redis: NewRing nil options

Error message

redis: NewRing nil options

What it means

Error "redis: NewRing nil options" thrown in redis/go-redis.

Source

Thrown at ring.go:629

//
// Ring should be used when you need multiple Redis servers for caching
// and can tolerate losing data when one of the servers dies.
// Otherwise you should use Redis Cluster.
type Ring struct {
	cmdable
	hooksMixin

	opt               *RingOptions
	sharding          *ringSharding
	cmdsInfoCache     *cmdsInfoCache
	heartbeatCancelFn context.CancelFunc
}

// NewRing returns a Redis Ring client to the Redis Server specified by RingOptions.
// Passing nil RingOptions will cause a panic.
func NewRing(opt *RingOptions) *Ring {
	if opt == nil {
		panic("redis: NewRing nil options")
	}
	// Shallow-copy the options: the ring-wide HIMPORT registry is carried
	// through them to shard construction, and reusing one caller-owned
	// RingOptions across several rings must not make the rings share (or
	// clobber each other's) registry.
	optCopy := *opt
	opt = &optCopy
	opt.init()
	// The registry must exist before the first shard is created; shards
	// adopt it in newRingShard.
	opt.himport = newHImportRegistry()

	hbCtx, hbCancel := context.WithCancel(context.Background())

	ring := Ring{
		opt:               opt,
		sharding:          newRingSharding(opt),
		heartbeatCancelFn: hbCancel,

View on GitHub (pinned to c5cad058c7)

When it happens

Trigger: Thrown at ring.go:629 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of redis/go-redis@c5cad058c7 (2026-09-01). Data as JSON: /api/errors/f3265bc2ea319a55. Report an issue: GitHub.