github-vet / github-vet/rangeloop-pointer-findings
luizvnasc/cwbus-hist: store/mongo.go; 26 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [luizvnasc/cwbus-hist](https://www.github.com/luizvnasc/cwbus-hist) at [store/mongo.go](https://github.com/luizvnasc/cwbus-hist/blob/22a6414fc9d99d51e9d0e3780ecfe073cc155fa0/store/mongo.go#L47-L72)
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 linha is reassigned at line 62
[Click here to see the code in its original context.](https://github.com/luizvnasc/cwbus-hist/blob/22a6414fc9d99d51e9d0e3780ecfe073cc155fa0/store/mongo.go#L47-L72)
Click here to show the 26 line(s) of Go which triggered the analyzer.
```go
for _, linha := range linhas {
var l *model.Linha
for _, linhaCadastrada := range linhasCadastradas {
if linhaCadastrada.Codigo == linha.Codigo {
l = &linhaCadastrada
l.Pontos = linha.Pontos
l.Tabela = linha.Tabela
break
}
}
if l != nil {
//fmt.Printf("linha %q já cadastrada\n", l.Codigo)
l.AtualizadoEm = time.Now().Unix()
} else {
//fmt.Printf("linha %q é nova\n", l.Codigo)
l = &linha
l.AtualizadoEm = time.Now().Unix()
l.CriadoEm = time.Now().Unix()
}
operation := mongo.NewUpdateOneModel()
operation.SetUpsert(true)
operation.SetFilter(bson.M{"cod": l.Codigo})
operation.SetUpdate(*l)
operations = append(operations, operation)
}
```
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: 22a6414fc9d99d51e9d0e3780ecfe073cc155fa0
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.