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

     1  package pkg
     2  
     3  func fn(s string) {
     4  	for _, r := range s {
     5  		println(r)
     6  	}
     7  
     8  	for _, r := range []rune(s) { // MATCH "should range over string"
     9  		println(r)
    10  	}
    11  
    12  	for i, r := range []rune(s) {
    13  		println(i)
    14  		println(r)
    15  	}
    16  
    17  	x := []rune(s)
    18  	for _, r := range x { // MATCH "should range over string"
    19  		println(r)
    20  	}
    21  
    22  	y := []rune(s)
    23  	for _, r := range y {
    24  		println(r)
    25  	}
    26  	println(y[0])
    27  }