github-vet / github-vet/rangeloop-pointer-findings
cloudreve/Cloudreve: models/scripts/storage.go; 11 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [cloudreve/Cloudreve](https://www.github.com/cloudreve/Cloudreve) at [models/scripts/storage.go](https://github.com/cloudreve/Cloudreve/blob/61e6d9b591a6416067d0ea935b9e9aba28e5c468/models/scripts/storage.go#L26-L36)
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.
> function call which takes a reference to user at line 34 may start a goroutine
[Click here to see the code in its original context.](https://github.com/cloudreve/Cloudreve/blob/61e6d9b591a6416067d0ea935b9e9aba28e5c468/models/scripts/storage.go#L26-L36)
Click here to show the 11 line(s) of Go which triggered the analyzer.
```go
for _, user := range res {
// 计算正确的容量
var total storageResult
model.DB.Model(&model.File{}).Where("user_id = ?", user.ID).Select("sum(size) as total").Scan(&total)
// 更新用户的容量
if user.Storage != total.Total {
util.Log().Info("将用户 [%s] 的容量由 %d 校准为 %d", user.Email,
user.Storage, total.Total)
model.DB.Model(&user).Update("storage", total.Total)
}
}
```
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: 61e6d9b591a6416067d0ea935b9e9aba28e5c468
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.