github-vet / github-vet/rangeloop-pointer-findings
norouter/norouter: pkg/manager/manager.go; 44 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [norouter/norouter](https://www.github.com/norouter/norouter) at [pkg/manager/manager.go](https://github.com/norouter/norouter/blob/92db06cbe21905996191e56756578aa56edb6a1d/pkg/manager/manager.go#L61-L104)
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 cc used in defer or goroutine at line 92
[Click here to see the code in its original context.](https://github.com/norouter/norouter/blob/92db06cbe21905996191e56756578aa56edb6a1d/pkg/manager/manager.go#L61-L104)
Click here to show the 44 line(s) of Go which triggered the analyzer.
```go
for vip, cc := range r.ccSet.ByVIP {
configPkt := &stream.Packet{
Type: stream.TypeJSON,
Payload: cc.configRequestMsg,
}
cc.cmd.Stderr = &stderrWriter{
vip: cc.VIP,
hostname: cc.Hostname,
}
stdin, err := cc.cmd.StdinPipe()
if err != nil {
return err
}
sender := &stream.Sender{
Writer: stdin,
}
r.senders[vip] = sender
stdout, err := cc.cmd.StdoutPipe()
if err != nil {
return err
}
receiver := &stream.Receiver{
Reader: stdout,
}
r.receivers[vip] = receiver
logrus.Debugf("starting client for %s (%s): %q", cc.Hostname, vip, cc.cmd.String())
if err := cc.cmd.Start(); err != nil {
return err
}
// TODO: notify if a client exits
defer func() {
logrus.Warnf("exiting client: %q", cc.String())
if cc.cmd.Process != nil {
if err := cc.cmd.Process.Signal(os.Interrupt); err != nil {
logrus.WithError(err).Errorf("error while sending os.Interrupt to %s(%s)", cc.Hostname, vip)
cc.cmd.Process.Kill()
}
}
}()
logrus.Debugf("sending Configure packet to %s: %q", cc.Hostname, string(cc.configRequestMsg))
if err := sender.Send(configPkt); err != nil {
return err
}
}
```
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: 92db06cbe21905996191e56756578aa56edb6a1d
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.