github-vet / github-vet/rangeloop-pointer-findings
HydeZhaoToo/HA_LVS: main.go; 72 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [HydeZhaoToo/HA_LVS](https://www.github.com/HydeZhaoToo/HA_LVS) at [main.go](https://github.com/HydeZhaoToo/HA_LVS/blob/a41b96d20034e4f4d511f66bbcee863443e662e5/main.go#L164-L235)
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 j used in defer or goroutine at line 172
[Click here to see the code in its original context.](https://github.com/HydeZhaoToo/HA_LVS/blob/a41b96d20034e4f4d511f66bbcee863443e662e5/main.go#L164-L235)
Click here to show the 72 line(s) of Go which triggered the analyzer.
```go
for j, v := range dest_lvs {
//判断检测服务类型
if v.Type == "http" {
//检测服务
if err := check_http(v.realip); err != nil {
//服务是否在线
if !v.after {
go func() {
err := sendmail(mailini_tmp, fmt.Sprintf("HostName:%s
Ip:%s
ErrorL%s", j, v.realip, err.Error()))
if err != nil {
log.Println(err)
}
conn, err := ssh_dial(v.vip+":22", mysql_user, mysql_passwd)
if err != nil {
log.Println(err)
}
err = ssh_exec(conn, v)
if err != nil {
log.Println(err)
}
}()
}
} else {
if v.after {
//检测恢复在线
go func() {
conn, err := ssh_dial(v.vip+":22", mysql_user, mysql_passwd)
if err != nil {
log.Println(err)
}
err = ssh_exec(conn, v)
if err != nil {
log.Println(err)
}
}()
}
}
}
if v.Type == "mysql" {
if err := check_slave(v.realip); err != nil {
if !v.after {
go func() {
err = sendmail(mailini_tmp, fmt.Sprintf("HostName:%s
Ip:%s
Error:%s", j, v.realip, err.Error()))
if err != nil {
log.Println(err)
}
conn, err := ssh_dial(v.vip+":22", mysql_user, mysql_passwd)
if err != nil {
log.Println(err)
}
err = ssh_exec(conn, v)
if err != nil {
log.Println(err)
}
}()
}
} else {
if v.after {
go func() {
conn, err := ssh_dial(v.vip+":22", mysql_user, mysql_passwd)
if err != nil {
log.Println(err)
}
err = ssh_exec(conn, v)
if err != nil {
log.Println(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: a41b96d20034e4f4d511f66bbcee863443e662e5
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.