github-vet / github-vet/rangeloop-pointer-findings
akky2501/hiddentypes: testdata/src/a/a.go; 29 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [akky2501/hiddentypes](https://www.github.com/akky2501/hiddentypes) at [testdata/src/a/a.go](https://github.com/akky2501/hiddentypes/blob/3d84f13498dc32d0326562cf12502425b3872153/testdata/src/a/a.go#L28-L56)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.
> reference to person is reassigned at line 33
[Click here to see the code in its original context.](https://github.com/akky2501/hiddentypes/blob/3d84f13498dc32d0326562cf12502425b3872153/testdata/src/a/a.go#L28-L56)
Click here to show the 29 line(s) of Go which triggered the analyzer.
```go
for _, person := range people {
if person.Age < 18 {
fmt.Printf("Found not adult: %v\n", person) // OK
log.Printf("Found not adult: %v\n", person) // want "NG"
p := &person
log.Printf("Found not adult: %v\n", p) // (wish) want "NG"
f := log.Printf
f("test: %v\n", person) // want "NG"
g := log.Printf
if person.Age == 5 {
g = log.Printf
}
g("test: %v\n", person) // OK
wrappedLog(person) // want "NG"
wrappedLog2(person) // (wish) OK
show(log.Printf, person) // OK
return false
}
if person.Age < 0 {
log.Printf("Panic: %v\n", xxx) // OK
log.Panicf("impossible human: %v", person) // want "NG"
}
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 3d84f13498dc32d0326562cf12502425b3872153
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.