github-vet / github-vet/rangeloop-pointer-findings
MoonBabyLabs/kek: doc.go; 32 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [MoonBabyLabs/kek](https://www.github.com/MoonBabyLabs/kek) at [doc.go](https://github.com/MoonBabyLabs/kek/blob/5859b466508b78a17ae330ac9eba29cc00307e95/doc.go#L268-L299)
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 attr used in defer or goroutine at line 274
[Click here to see the code in its original context.](https://github.com/MoonBabyLabs/kek/blob/5859b466508b78a17ae330ac9eba29cc00307e95/doc.go#L268-L299)
Click here to show the 32 line(s) of Go which triggered the analyzer.
```go
for attr := range kd.Attributes {
val := kd.Attributes[attr]
go func() {
strVal, isStr := val.(string)
if isStr {
deletedAttrs <- kd.store.Delete(FIELD_DIR + attr + "/" + strVal + "/" + kd.Id)
}
valInt, isInt := val.(int)
if isInt {
deletedAttrs <- kd.store.Delete(FIELD_DIR + attr + "/" + strconv.Itoa(valInt) + "/" + kd.Id)
}
strSlice, isStrSlice := val.([]string)
if isStrSlice {
for _, val := range strSlice {
go kd.store.Delete(FIELD_DIR + attr + "/" + val + "/" + kd.Id)
}
}
intSlice, isIntSlice := val.([]int)
if isIntSlice {
for _, val := range intSlice {
deletedAttrs <- kd.store.Delete(FIELD_DIR + attr + "/" + strconv.Itoa(val) + "/" + kd.Id)
}
}
}()
}
```
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: 5859b466508b78a17ae330ac9eba29cc00307e95
Contributor guide
No contributing guide indexed for this repository
Research direction
Read doc.go at lines 268-299 and inspect the goroutines that use the range variable attr. Compare the analyzer's finding with the intended behavior, then classify the instance as Bug, Mitigated, or Desirable Behavior using the linked classification guidance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100