1
0
mirror of https://github.com/mgechev/revive.git synced 2024-12-12 10:44:59 +02:00
revive/testdata/range-val-address.go

48 lines
1.1 KiB
Go
Raw Normal View History

package fixtures
func rangeValAddress() {
m := map[string]*string{}
mySlice := []string{"A", "B", "C"}
for _, value := range mySlice {
m["address"] = &value // MATCH /suspicious assignment of 'value'. range-loop variables always have the same address/
}
}
func rangeValAddress2() {
m := map[string]*string{}
mySlice := []string{"A", "B", "C"}
for i := range mySlice {
m["address"] = &mySlice[i]
}
}
func rangeValAddress3() {
m := map[string]*string{}
mySlice := []string{"A", "B", "C"}
for _, value := range mySlice {
a := &value // MATCH /suspicious assignment of 'value'. range-loop variables always have the same address/
m["address"] = a
}
}
func rangeValAddress4() {
m := []*string{}
mySlice := []string{"A", "B", "C"}
for _, value := range mySlice {
m = append(m, &value) // MATCH /suspicious assignment of 'value'. range-loop variables always have the same address/
}
}
func rangeValAddress5() {
m := map[*string]string{}
mySlice := []string{"A", "B", "C"}
for _, value := range mySlice {
m[&value] = value // MATCH /suspicious assignment of 'value'. range-loop variables always have the same address/
}
}