go-kratos/kratos · error
container.group: can't assign a nil to the new function
Error message
container.group: can't assign a nil to the new function
What it means
Error "container.group: can't assign a nil to the new function" thrown in go-kratos/kratos.
Source
Thrown at internal/group/group.go:21
// And it will cache all the objects to reduce the creation of object.
package group
import "sync"
// Factory is a function that creates an object of type T.
type Factory[T any] func() T
// Group is a lazy load container.
type Group[T any] struct {
factory func() T
vals map[string]T
sync.RWMutex
}
// NewGroup news a group container.
func NewGroup[T any](factory Factory[T]) *Group[T] {
if factory == nil {
panic("container.group: can't assign a nil to the new function")
}
return &Group[T]{
factory: factory,
vals: make(map[string]T),
}
}
// Get gets the object by the given key.
func (g *Group[T]) Get(key string) T {
g.RLock()
v, ok := g.vals[key]
if ok {
g.RUnlock()
return v
}
g.RUnlock()
// slow path for group don`t have specified key valueView on GitHub (pinned to 668db92c2c)
When it happens
Trigger: Thrown at internal/group/group.go:21 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of go-kratos/kratos@668db92c2c (2026-08-16).
Data as JSON: /api/errors/d53e3983f1195363.
Report an issue: GitHub.