From: qydysky Date: Sun, 30 Mar 2025 16:11:54 +0000 (+0800) Subject: 1 (#40) X-Git-Tag: v0.28.20250330161202 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=2a90787dc822d6670d96b7227a9cde36509e1b0c;p=part%2F.git 1 (#40) --- 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]{})