From 997663a4adadba154f3b1d5afc823890cd31009e Mon Sep 17 00:00:00 2001 From: Larvan2 <78135608+Larvan2@users.noreply.github.com> Date: Sat, 23 Dec 2023 13:10:29 +0800 Subject: [PATCH] chore: avoid return nil. fix #930 --- adapter/adapter.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/adapter/adapter.go b/adapter/adapter.go index 695033b79..da6171f17 100644 --- a/adapter/adapter.go +++ b/adapter/adapter.go @@ -76,11 +76,10 @@ func (p *Proxy) ListenPacketContext(ctx context.Context, metadata *C.Metadata, o // DelayHistory implements C.Proxy func (p *Proxy) DelayHistory() []C.DelayHistory { queueM := p.history.Copy() - var histories []C.DelayHistory + histories := []C.DelayHistory{} for _, item := range queueM { histories = append(histories, item) } - return histories } @@ -91,8 +90,7 @@ func (p *Proxy) DelayHistoryForTestUrl(url string) []C.DelayHistory { if state, ok := p.extra.Load(url); ok { queueM = state.history.Copy() } - - var histories []C.DelayHistory + histories := []C.DelayHistory{} for _, item := range queueM { histories = append(histories, item) }