github.com/serversong/goreporter@v0.0.0-20200325104552-3cfaf44fd178/linters/simplecode/testdata/range.go (about)

     1  package pkg
     2  
     3  func fn() {
     4  	var m map[string]int
     5  
     6  	// with :=
     7  	for x, _ := range m {
     8  		_ = x
     9  	}
    10  	// with =
    11  	var y string
    12  	_ = y
    13  	for y, _ = range m {
    14  	}
    15  
    16  	for _ = range m { // MATCH /should omit values.*range.*equivalent.*for range/
    17  	}
    18  
    19  	for _, _ = range m { // MATCH /should omit values.*range.*equivalent.*for range/
    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  }