github-vet / github-vet/rangeloop-pointer-findings
TetAlius/GoSyncMyCalendars: worker/worker.go; 20 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [TetAlius/GoSyncMyCalendars](https://www.github.com/TetAlius/GoSyncMyCalendars) at [worker/worker.go](https://github.com/TetAlius/GoSyncMyCalendars/blob/b10e7cbcce5d28b057e051a3bb252d3ac4c402f5/worker/worker.go#L91-L110)
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 toSync used in defer or goroutine at line 97
[Click here to see the code in its original context.](https://github.com/TetAlius/GoSyncMyCalendars/blob/b10e7cbcce5d28b057e051a3bb252d3ac4c402f5/worker/worker.go#L91-L110)
Click here to show the 20 line(s) of Go which triggered the analyzer.
```go
for _, toSync := range event.GetRelations() {
err := toSync.GetCalendar().GetAccount().Refresh()
go worker.database.UpdateAccount(toSync.GetCalendar().GetAccount())
err = worker.synchronizeEvents(event, toSync)
if err != nil && reflect.TypeOf(err).Kind() != reflect.TypeOf(SynchronizeError{}).Kind() {
go func() {
for toSync.CanProcessAgain() {
toSync.IncrementBackoff()
err := worker.synchronizeEvents(event, toSync)
if err != nil {
continue
} else {
//Synchronized correctly
break
}
}
}()
}
}
```
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: b10e7cbcce5d28b057e051a3bb252d3ac4c402f5
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading worker/worker.go lines 91-110 and the Go range-loop capture behavior reported for toSync. Confirm each goroutine uses the intended relation, then verify the analyzer no longer reports the finding and that the synchronization behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100