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

lab259/hermes: examples/todos/api/todos/index.go; 4 LoC

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

Description

Found a possible issue in [lab259/hermes](https://www.github.com/lab259/hermes) at [examples/todos/api/todos/index.go](https://github.com/lab259/hermes/blob/f2ae1099d8693dc819331805b5dab19609b622a5/examples/todos/api/todos/index.go#L8-L11)

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 todo is reassigned at line 9

[Click here to see the code in its original context.](https://github.com/lab259/hermes/blob/f2ae1099d8693dc819331805b5dab19609b622a5/examples/todos/api/todos/index.go#L8-L11)

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

```go
for _, todo := range db {
list[idx] = &todo
idx++
}

```

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: f2ae1099d8693dc819331805b5dab19609b622a5

Contributor guide

No contributing guide indexed for this repository

Research direction

Read examples/todos/api/todos/index.go, especially the range loop over db and the assignment to list[idx]. Determine whether taking a reference to the loop variable is a real bug, mitigated, or desirable behavior in this context. Done means classifying the finding with the requested reaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.