github-vet / github-vet/rangeloop-pointer-findings
pulcy/helix: service/service.go; 50 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [pulcy/helix](https://www.github.com/pulcy/helix) at [service/service.go](https://github.com/pulcy/helix/blob/23d919222e1dd8654039ad6364c91a93ab956c38/service/service.go#L237-L286)
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 s used in defer or goroutine at line 272
[Click here to see the code in its original context.](https://github.com/pulcy/helix/blob/23d919222e1dd8654039ad6364c91a93ab956c38/service/service.go#L237-L286)
Click here to show the 50 line(s) of Go which triggered the analyzer.
```go
for _, s := range services {
if initer, ok := s.(ServiceIniter); ok {
if err := initer.Init(sctx, deps, flags); err != nil {
return maskAny(err)
}
}
if sNode, ok := s.(ServiceNodeInitializer); ok {
wg := sync.WaitGroup{}
errors := make(chan error, len(clients))
defer close(errors)
for i, client := range clients {
wg.Add(1)
go func(client util.SSHClient, node *Node) {
defer wg.Done()
if err := sNode.InitNode(node, client, sctx, deps, flags); err != nil {
errors <- maskAny(err)
}
}(client, nodes[i])
}
wg.Wait()
select {
case err := <-errors:
return maskAny(err)
default:
// Continue
}
}
if sMachine, ok := s.(ServiceMachines); ok {
wg := sync.WaitGroup{}
errors := make(chan error, len(clients))
defer close(errors)
for i, client := range clients {
wg.Add(1)
go func(client util.SSHClient, node Node) {
defer wg.Done()
deps.Logger.Info().Msgf("Setting up %s service on %s", s.Name(), node.Name)
if err := sMachine.InitMachine(node, client, sctx, deps, flags); err != nil {
errors <- maskAny(err)
}
}(client, *nodes[i])
}
wg.Wait()
select {
case err := <-errors:
return maskAny(err)
default:
// Continue
}
}
}
```
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: 23d919222e1dd8654039ad6364c91a93ab956c38
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.