Skip to content

Commit ea900d3

Browse files
karamaru-alphaldez
authored andcommitted
update: add std lib to testcase
Signed-off-by: karamaru-alpha <mrnk3078@gmail.com>
1 parent 8c2d667 commit ea900d3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test/testdata/copyloopvar.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
//golangcitest:args -Ecopyloopvar
22
package testdata
33

4+
import "fmt"
5+
46
func copyloopvarCase1() {
57
slice := []int{1, 2, 3}
68
fns := make([]func(), 0, len(slice)*2)
79
for i, v := range slice {
810
i := i // want `It's unnecessary to copy the loop variable "i"`
911
fns = append(fns, func() {
10-
_ = i
12+
fmt.Println(i)
1113
})
1214
_v := v // want `It's unnecessary to copy the loop variable "v"`
1315
fns = append(fns, func() {
14-
_ = _v
16+
fmt.Println(_v)
1517
})
1618
}
1719
for _, fn := range fns {
@@ -25,7 +27,7 @@ func copyloopvarCase2() {
2527
for i := 1; i <= loopCount; i++ {
2628
i := i // want `It's unnecessary to copy the loop variable "i"`
2729
fns = append(fns, func() {
28-
_ = i
30+
fmt.Println(i)
2931
})
3032
}
3133
for _, fn := range fns {

0 commit comments

Comments
 (0)