Skip to content

Files

Latest commit

 

History

History
12 lines (7 loc) · 463 Bytes

range-val-in-closure.md

File metadata and controls

12 lines (7 loc) · 463 Bytes

Pattern: Use of range value in closure

Issue: -

Description

Range variables in a loop are reused at each iteration; therefore a goroutine created in a loop will point to the range variable with from the upper scope. This way, the goroutine could use the variable with an undesired value. This rule warns when a range value (or index) is used inside a closure.

Further Reading