From 17eefa152f2041d8a28cf95d7cd4c53a37629365 Mon Sep 17 00:00:00 2001 From: hupeh Date: Sun, 15 Oct 2023 15:25:29 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/app/app.go | 6 +++++- pkg/app/stats.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/app/app.go b/pkg/app/app.go index 852e4f3..1f9e17b 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -100,7 +100,11 @@ func Loop() error { // 然后才可以退出主循环 checkPubsEmpty() setStatus(Stopped) - return ctx.Err() + err := ctx.Err() + if errors.Is(err, context.Canceled) { + return nil + } + return err } // We don't want to exit until we've received at least one message. diff --git a/pkg/app/stats.go b/pkg/app/stats.go index fdffc7f..6775ae4 100644 --- a/pkg/app/stats.go +++ b/pkg/app/stats.go @@ -40,5 +40,5 @@ func initMemoryProfile(memprof string) { func freeStats() { newStats := reflect.New(reflect.TypeOf(stats)) - reflect.ValueOf(stats).Set(newStats.Elem()) + reflect.ValueOf(&stats).Elem().Set(newStats.Elem()) }