github-vet / github-vet/rangeloop-pointer-findings
whencome/etlogger: service.go; 10 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [whencome/etlogger](https://www.github.com/whencome/etlogger) at [service.go](https://github.com/whencome/etlogger/blob/9e4d4982af7021d9a21260fe802d614fbe403101/service.go#L70-L79)
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 service used in defer or goroutine at line 73
[Click here to see the code in its original context.](https://github.com/whencome/etlogger/blob/9e4d4982af7021d9a21260fe802d614fbe403101/service.go#L70-L79)
Click here to show the 10 line(s) of Go which triggered the analyzer.
```go
for _, service := range loggerServices {
go func() {
now := time.Now()
if now.Sub(service.LastWriteTime) >= service.Config.ExpireDuration {
fmt.Printf("%s expired \n", service.Category)
closeLoggerService(service)
service.LogHandler.Stop() <- true
}
}()
}
```
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: 9e4d4982af7021d9a21260fe802d614fbe403101
Contributor guide
No contributing guide indexed for this repository
Research direction
Read service.go lines 70-79 and inspect how the goroutine uses service from the range loop. Reproduce or reason about whether each goroutine can observe the wrong service, then classify the finding with the requested reaction; done means a Bug, Mitigated, or Desirable Behavior classification.
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
- Mostly clear
- Newbie friendliness
- 38/100