From 2a90787dc822d6670d96b7227a9cde36509e1b0c Mon Sep 17 00:00:00 2001 From: qydysky Date: Mon, 31 Mar 2025 00:11:54 +0800 Subject: [PATCH] 1 (#40) --- component2/comp.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/component2/comp.go b/component2/comp.go index 5d150e6..d87639b 100644 --- a/component2/comp.go +++ b/component2/comp.go @@ -35,6 +35,12 @@ func Register[TargetInterface any](id string, _interface TargetInterface) error return nil } +func RegisterOrPanic[TargetInterface any](id string, _interface TargetInterface) { + if e := Register(id, _interface); e != nil { + panic(e) + } +} + func Get[TargetInterface any](id string, prefunc ...PreFunc[TargetInterface]) (_interface TargetInterface) { if len(prefunc) == 0 { prefunc = append(prefunc, PreFuncErr[TargetInterface]{}) -- 2.39.2