github-vet / github-vet/rangeloop-pointer-findings
gebv/ffsm: fsm.go; 51 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [gebv/ffsm](https://www.github.com/gebv/ffsm) at [fsm.go](https://github.com/gebv/ffsm/blob/96f90d78dea231aefa4d17d47999f1ec3ffd4b24/fsm.go#L176-L226)
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 _i used in defer or goroutine at line 193
[Click here to see the code in its original context.](https://github.com/gebv/ffsm/blob/96f90d78dea231aefa4d17d47999f1ec3ffd4b24/fsm.go#L176-L226)
Click here to show the 51 line(s) of Go which triggered the analyzer.
```go
for _i, actionFn := range actions {
actionStart = time.Now()
actionRes = make(chan resultOfActionTransition, 1)
// For simple FSM, without transition handlers
if actionFn == nil {
continue
}
go func(ctx context.Context) {
defer func() {
if r := recover(); r != nil {
actionRes <- resultOfActionTransition{
err: dispatcherError{
Recover: r,
SrcState: current,
DstState: m.next,
IndexAction: _i,
DebugStack: string(debug.Stack()),
},
}
return
}
}()
ctx, err := actionFn(nextCtx)
actionRes <- resultOfActionTransition{
err: err,
ctx: ctx,
}
}(nextCtx)
// waiting done action
select {
case done := <-actionRes:
nextCtx = done.ctx
err = done.err
}
actName := fmt.Sprintf("%q -> %q #%d", current, m.next, _i)
e.mActionDuration.WithLabelValues(actName).Observe(float64(time.Since(actionStart).Nanoseconds() / int64(time.Millisecond)))
e.mActionRequest.WithLabelValues(actName).Inc()
if err != nil {
// exit transition, because there was an error on one
// of the handlers of transition
break
}
// forend actions
}
```
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: 96f90d78dea231aefa4d17d47999f1ec3ffd4b24
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.