github-vet / github-vet/rangeloop-pointer-findings

d4l3k/etcdummy: etcdummy.go; 21 LoC

Open
#12,196 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [d4l3k/etcdummy](https://www.github.com/d4l3k/etcdummy) at [etcdummy.go](https://github.com/d4l3k/etcdummy/blob/4a1e6135a56eed21ba9499ad1243b006a836bf7e/etcdummy.go#L354-L374)

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 kv was used in a composite literal at line 363

[Click here to see the code in its original context.](https://github.com/d4l3k/etcdummy/blob/4a1e6135a56eed21ba9499ad1243b006a836bf7e/etcdummy.go#L354-L374)

Click here to show the 21 line(s) of Go which triggered the analyzer.

```go
for k, kv := range s.KV {
if kv.Lease == l.ID {
for _, w := range s.Watches {
if w.Match(k) {
if err := w.stream.Send(&etcdserverpb.WatchResponse{
WatchId: w.ID,
Events: []*mvccpb.Event{
{
Type: mvccpb.DELETE,
PrevKv: &kv,
},
},
}); err != nil {
return err
}
}
}

delete(s.KV, k)
}
}

```

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: 4a1e6135a56eed21ba9499ad1243b006a836bf7e

Contributor guide

No contributing guide indexed for this repository

Research direction

Read the linked etcdummy.go context at lines 354-374 and review the analyzer message about the reference to kv in the composite literal. Decide whether this is a bug, mitigated issue, or desirable behavior, then leave the corresponding reaction on the issue; completion is the classification reaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devtools
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.