github-vet / github-vet/rangeloop-pointer-findings
lixiangyun/tcpproxy: engine/tcp.go; 33 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [lixiangyun/tcpproxy](https://www.github.com/lixiangyun/tcpproxy) at [engine/tcp.go](https://github.com/lixiangyun/tcpproxy/blob/60679cfeffe30fef10580a84fe62afb14f1858cc/engine/tcp.go#L159-L191)
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 v used in defer or goroutine at line 188
[Click here to see the code in its original context.](https://github.com/lixiangyun/tcpproxy/blob/60679cfeffe30fef10580a84fe62afb14f1858cc/engine/tcp.go#L159-L191)
Click here to show the 33 line(s) of Go which triggered the analyzer.
```go
for _, v := range listeners {
var localtls *tls.Config
var remotetls *tls.Config
tls := TlsGet(v.Tlsname)
if tls != nil {
localtls = TlsServerConfig(tls)
}
cluster := ClusterGet(v.Cluster)
if cluster == nil {
log.Fatalf("not found %s cluster.", v.Cluster)
}
if len(cluster.Endpoint) == 0 {
log.Fatalf("not found %s cluster endpoint.", v.Cluster)
}
tls = TlsGet(cluster.TlsName)
if tls != nil {
remotetls = TlsClientConfig(tls, cluster.Endpoint[0])
}
tcoporxy := NewTcpProxy(v.Address, localtls, cluster.Endpoint, remotetls)
go func() {
err := tcoporxy.Start()
if err != nil {
log.Fatalf("tcp proxy start failed %v.", v)
}
}()
}
```
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: 60679cfeffe30fef10580a84fe62afb14f1858cc
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.