In general it’s a bad idea to reuse/recycle variables (see: Software Design/Don’t reuse a variable). It makes code less readable, debugging more difficult, and can lead to bad designs.
The following sections will highlight some issues with reused/recycling variables in Go.
range is a Go built-in keyword provided to iterate over arrays and slices. The syntax is shorter than C-style for loops ForStmt = "for" [ Condition | ForClause | RangeClause ] Block ., but the way it works may be confusing at first.
Check out the following code snippet:
Notice that the address of