github-vet / github-vet/rangeloop-pointer-findings
webtao520/golang_project: go常见错误总结/golang在遍历slice中的坑.go; 3 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [webtao520/golang_project](https://www.github.com/webtao520/golang_project) at [go常见错误总结/golang在遍历slice中的坑.go](https://github.com/webtao520/golang_project/blob/645f5868afd754443683a1e889e8481e5a623b80/go常见错误总结/golang在遍历slice中的坑.go#L25-L27)
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 stu is reassigned at line 26
[Click here to see the code in its original context.](https://github.com/webtao520/golang_project/blob/645f5868afd754443683a1e889e8481e5a623b80/go常见错误总结/golang在遍历slice中的坑.go#L25-L27)
Click here to show the 3 line(s) of Go which triggered the analyzer.
```go
for _, stu := range stus {
m[stu.Name] = &stu // 将临时变量stu的地址给map,最后所有的地址都为同样的一个值 stu是值拷贝,而且这里是一个临时变量,用的同一个地址的空间
}
```
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: 645f5868afd754443683a1e889e8481e5a623b80
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.