github-vet / github-vet/rangeloop-pointer-findings
mickeyzzc/ucloud_exporter: umonitor/udb.go; 42 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [mickeyzzc/ucloud_exporter](https://www.github.com/mickeyzzc/ucloud_exporter) at [umonitor/udb.go](https://github.com/mickeyzzc/ucloud_exporter/blob/cdab3430ab63531a463cbc5b48042be65b14a0c7/umonitor/udb.go#L93-L134)
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.
> reference to udbTypeName is reassigned at line 94
[Click here to see the code in its original context.](https://github.com/mickeyzzc/ucloud_exporter/blob/cdab3430ab63531a463cbc5b48042be65b14a0c7/umonitor/udb.go#L93-L134)
Click here to show the 42 line(s) of Go which triggered the analyzer.
```go
for _, udbTypeName := range typeUDBnamelist {
udbReq.ClassType = &udbTypeName
udbList, _ := uclient.DescribeUDBInstance(udbReq)
if udbList.TotalCount == 0 {
selfConf.logger.Debug("Not resource.",
zap.String("Project", string(projectName)),
zap.String("Region", string(region)),
zap.String("Type", string(udbTypeName)),
)
udbChan <- nil
continue
}
// 匿名函数
selfFun := func(db interface{}, selfProjectID, selfProjectName, selfRegion, sqlType string) {
switch db.(type) {
case udb.UDBInstanceSet:
masterResource(db.(udb.UDBInstanceSet), selfProjectID, selfProjectName, selfRegion, sqlType)
case udb.UDBSlaveInstanceSet:
slaveResource(db.(udb.UDBSlaveInstanceSet), selfProjectID, selfProjectName, selfRegion, sqlType)
default:
selfConf.logger.Warn("resource is not udb ",
zap.Any("Type", reflect.TypeOf(db)),
)
return
}
}
//
for i := 0; i < udbList.TotalCount; i = i + limit {
offset = i
if offset > 0 {
udbList, _ = uclient.DescribeUDBInstance(udbReq)
}
for _, udb := range udbList.DataSet {
selfFun(udb, projectID, projectName, region, udbTypeName)
for _, slaveDB := range udb.DataSet {
selfFun(slaveDB, projectID, projectName, region, udbTypeName)
}
}
}
}
```
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: cdab3430ab63531a463cbc5b48042be65b14a0c7
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.