From ecf0fe57cdf56c2ddbbae7105527e24fa98cde99 Mon Sep 17 00:00:00 2001 From: lbbniu Date: Fri, 5 May 2023 12:11:52 +0800 Subject: [PATCH] fix(bug): uninitialized app attribute in tars.Admin --- tars/admin.go | 4 ++++ tars/application.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tars/admin.go b/tars/admin.go index 9b6eb4b4..075d18f2 100755 --- a/tars/admin.go +++ b/tars/admin.go @@ -21,6 +21,10 @@ type Admin struct { type adminFn func(string) (string, error) +func newAdmin(app *application) *Admin { + return &Admin{app: app} +} + // RegisterAdmin register admin functions func RegisterAdmin(name string, fn adminFn) { defaultApp.RegisterAdmin(name, fn) diff --git a/tars/application.go b/tars/application.go index dffd0085..b89db3ec 100755 --- a/tars/application.go +++ b/tars/application.go @@ -342,7 +342,7 @@ func (a *application) Run() { // add adminF if _, ok := defaultApp.tarsConfig["AdminObj"]; ok { adf := new(adminf.AdminF) - ad := new(Admin) + ad := newAdmin(a) AddServant(adf, ad, "AdminObj") }