From 0d3483e7c36448937c3e465655fd3d0b3f03966e Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 5 Mar 2024 21:16:35 +0800 Subject: [PATCH] xdepthmaker: fix loopvar issue --- pkg/strategy/xdepthmaker/profitfixer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/strategy/xdepthmaker/profitfixer.go b/pkg/strategy/xdepthmaker/profitfixer.go index 93234eb86..66905580e 100644 --- a/pkg/strategy/xdepthmaker/profitfixer.go +++ b/pkg/strategy/xdepthmaker/profitfixer.go @@ -51,8 +51,10 @@ func (f *ProfitFixer) Fix(ctx context.Context, since, until time.Time, stats *ty var allTrades = make([]types.Trade, 0, 1000) g, subCtx := errgroup.WithContext(ctx) - for n, service := range f.sessions { + for n, s := range f.sessions { + // allocate a copy of the iteration variables sessionName := n + service := s g.Go(func() error { log.Infof("batch querying %s trade history from %s since %s until %s", f.market.Symbol, sessionName, since.String(), until.String()) trades, err := f.batchQueryTrades(subCtx, service, f.market.Symbol, since, until)