[bugfix] Fix incorrect per-loop variable capture (#2092)

These should be per iteration, not per loop. This was caught by running
a build with the loopvar experiment: go build -gcflags=-d=loopvar=2.
This commit is contained in:
Daenney 2023-08-09 18:40:32 +02:00 committed by GitHub
commit dbf487effb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 0 deletions

View file

@ -119,6 +119,7 @@ func (m *manager) Start() error {
// hasn't been accessed in the last hour.
go func() {
for now := range time.NewTicker(1 * time.Hour).C {
now := now // rescope
// Define the range function inside here,
// so that we can use the 'now' returned
// by the ticker, instead of having to call