github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/simple/s1005/testdata/src/example.com/CheckUnnecessaryBlank_go14/range_go14.go (about) 1 package pkg 2 3 func fn() { 4 var m map[string]int 5 6 // with := 7 for x, _ := range m { //@ diag(`unnecessary assignment to the blank identifier`) 8 _ = x 9 } 10 // with = 11 var y string 12 _ = y 13 for y, _ = range m { //@ diag(`unnecessary assignment to the blank identifier`) 14 } 15 16 for _ = range m { //@ diag(`unnecessary assignment to the blank identifier`) 17 } 18 19 for _, _ = range m { //@ diag(`unnecessary assignment to the blank identifier`) 20 } 21 22 // all OK: 23 for x := range m { 24 _ = x 25 } 26 for x, y := range m { 27 _, _ = x, y 28 } 29 for _, y := range m { 30 _ = y 31 } 32 var x int 33 _ = x 34 for y = range m { 35 } 36 for y, x = range m { 37 } 38 for _, x = range m { 39 } 40 }