github-vet / github-vet/rangeloop-pointer-findings
ruslanBik4/httpgo: models/db/qb/forms.go; 15 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [ruslanBik4/httpgo](https://www.github.com/ruslanBik4/httpgo) at [models/db/qb/forms.go](https://github.com/ruslanBik4/httpgo/blob/372a6cf8fe2b0c381b8a2c756c543367209d1d18/models/db/qb/forms.go#L24-L38)
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.
> range-loop variable fieldStrc used in defer or goroutine at line 30
[Click here to see the code in its original context.](https://github.com/ruslanBik4/httpgo/blob/372a6cf8fe2b0c381b8a2c756c543367209d1d18/models/db/qb/forms.go#L24-L38)
Click here to show the 15 line(s) of Go which triggered the analyzer.
```go
for _, fieldStrc := range table.schema.Rows {
defer func() {
result := recover()
switch err := result.(type) {
case schema.ErrNotFoundTable:
log.Println(table, fieldStrc)
case error:
panic(err)
case nil:
}
}()
table.AddField("", fieldStrc.COLUMN_NAME)
qb.fields = append(qb.fields, table.Fields[fieldStrc.COLUMN_NAME])
}
```
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: 372a6cf8fe2b0c381b8a2c756c543367209d1d18
Contributor guide
No contributing guide indexed for this repository
Research direction
Read models/db/qb/forms.go around lines 24-38, focusing on the range over table.schema.Rows and the deferred function using fieldStrc. Check whether the reported range-variable capture is a real issue in this context and whether the finding is already mitigated. Done means classifying it as Bug, Mitigated, or Desirable Behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100