{"record":{"id":"d53e3983f1195363","repo":"go-kratos/kratos","slug":"container-group-can-t-assign-a-nil-to-the-new-fun","errorCode":null,"errorMessage":"container.group: can't assign a nil to the new function","messagePattern":"container\\.group: can't assign a nil to the new function","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/group/group.go","lineNumber":21,"sourceCode":"// And it will cache all the objects to reduce the creation of object.\npackage group\n\nimport \"sync\"\n\n// Factory is a function that creates an object of type T.\ntype Factory[T any] func() T\n\n// Group is a lazy load container.\ntype Group[T any] struct {\n\tfactory func() T\n\tvals    map[string]T\n\tsync.RWMutex\n}\n\n// NewGroup news a group container.\nfunc NewGroup[T any](factory Factory[T]) *Group[T] {\n\tif factory == nil {\n\t\tpanic(\"container.group: can't assign a nil to the new function\")\n\t}\n\treturn &Group[T]{\n\t\tfactory: factory,\n\t\tvals:    make(map[string]T),\n\t}\n}\n\n// Get gets the object by the given key.\nfunc (g *Group[T]) Get(key string) T {\n\tg.RLock()\n\tv, ok := g.vals[key]\n\tif ok {\n\t\tg.RUnlock()\n\t\treturn v\n\t}\n\tg.RUnlock()\n\n\t// slow path for group don`t have specified key value","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/go-kratos/kratos/blob/668db92c2c001e9552594ba5a8aede8456af6d7e/internal/group/group.go#L3-L39","documentation":"Error \"container.group: can't assign a nil to the new function\" thrown in go-kratos/kratos.","triggerScenarios":"Thrown at internal/group/group.go:21 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"668db92c2c001e9552594ba5a8aede8456af6d7e","analyzedAt":"2026-08-16T02:07:20.704Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}