From: qydysky Date: Thu, 18 Apr 2024 16:23:05 +0000 (+0000) Subject: 1 X-Git-Tag: v0.28.20240418162752 X-Git-Url: http://127.0.0.1:8081/?a=commitdiff_plain;h=25f8b5a07e73768a1e89cb7acc424cac0ff8f22f;p=part%2F.git 1 --- diff --git a/component2/comp.go b/component2/comp.go index 833fa71..93d632d 100644 --- a/component2/comp.go +++ b/component2/comp.go @@ -33,11 +33,12 @@ func Register[TargetInterface any](pkgId string, _interface TargetInterface) err return nil } -func Get[TargetInterface any](pkgId string, defaultInterface ...TargetInterface) (_interface TargetInterface) { +func Get[TargetInterface any](pkgId string, init ...func(TargetInterface) TargetInterface) (_interface TargetInterface) { if tmp, ok := pkgInterfaceMap[pkgId].(TargetInterface); ok { + for i := 0; i < len(init); i++ { + tmp = init[i](tmp) + } return tmp - } else if len(defaultInterface) > 0 { - return defaultInterface[0] } else { panic(ErrGet) }