github-vet / github-vet/rangeloop-pointer-findings
rigglo/gql: execution.go; 39 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [rigglo/gql](https://www.github.com/rigglo/gql) at [execution.go](https://github.com/rigglo/gql/blob/56f703905f2b8e72e10ff92894905c453e4a5d59/execution.go#L349-L387)
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 fs used in defer or goroutine at line 368
[Click here to see the code in its original context.](https://github.com/rigglo/gql/blob/56f703905f2b8e72e10ff92894905c453e4a5d59/execution.go#L349-L387)
Click here to show the 39 line(s) of Go which triggered the analyzer.
```go
for rkey, fs := range gfields {
fieldName := fs[0].Name
if !strings.HasPrefix(fieldName, "__") {
res, err := ctx.schema.Subscription.Fields[fieldName].Resolver(
&resolveContext{
ctx: ctx.ctx, // this is the original context
gqlCtx: ctx, // execution context
args: coerceArgumentValues(ctx, []interface{}{rkey}, ctx.schema.Subscription, fs[0]),
parent: ctx.schema.RootValue, // root value
path: []interface{}{rkey},
},
)
if err != nil {
return nil, err
}
if ch, ok := res.(chan interface{}); ok {
go func() {
for v := range ch {
res, hasErr := completeValue(ctx, nil, ctx.schema.Subscription.Fields[fieldName].Type, fs, v)
if hasErr {
out <- &Result{
Data: nil,
Errors: ctx.res.Errors,
}
ctx.res.Errors = []*Error{}
}
out <- &Result{
Data: map[string]interface{}{
rkey: res,
},
}
}
close(out)
}()
}
return out, nil
}
}
```
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: 56f703905f2b8e72e10ff92894905c453e4a5d59
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.