github-vet / github-vet/rangeloop-pointer-findings
honglimin29/icenter: src/source_controller/coreservice/core/model/attribute.go; 35 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [honglimin29/icenter](https://www.github.com/honglimin29/icenter) at [src/source_controller/coreservice/core/model/attribute.go](https://github.com/honglimin29/icenter/blob/be0592b1ce5c636f005e3ceb97b2cedc4b3bf490/src/source_controller/coreservice/core/model/attribute.go#L56-L90)
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.
> function call which takes a reference to attr at line 67 may start a goroutine
[Click here to see the code in its original context.](https://github.com/honglimin29/icenter/blob/be0592b1ce5c636f005e3ceb97b2cedc4b3bf490/src/source_controller/coreservice/core/model/attribute.go#L56-L90)
Click here to show the 35 line(s) of Go which triggered the analyzer.
```go
for attrIdx, attr := range inputParam.Attributes {
if attr.IsPre {
if attr.PropertyID == common.BKInstNameField {
attr.PropertyName = util.FirstNotEmptyString(ctx.Lang.Language("common_property_"+attr.PropertyID), attr.PropertyName, attr.PropertyID)
}
}
attr.OwnerID = ctx.SupplierAccount
_, exists, err := m.isExists(ctx, attr.PropertyID, attr.Metadata)
if nil != err {
blog.Errorf("request(%s): it is failed, to check if the attribute's field propertyID(%s) is exists, error info is %s", ctx.ReqID, attr.PropertyID, err.Error())
addExceptionFunc(int64(attrIdx), err.(errors.CCErrorCoder), &attr)
continue
}
if exists {
dataResult.CreateManyInfoResult.Repeated = append(dataResult.CreateManyInfoResult.Repeated, metadata.RepeatedDataResult{
OriginIndex: int64(attrIdx),
Data: mapstr.NewFromStruct(attr, "field"),
})
continue
}
id, err := m.save(ctx, attr)
if nil != err {
blog.Errorf("request(%s): it is failed to save the attribute(%#v), error info is %s", ctx.ReqID, attr, err.Error())
addExceptionFunc(int64(attrIdx), err.(errors.CCErrorCoder), &attr)
continue
}
dataResult.CreateManyInfoResult.Created = append(dataResult.CreateManyInfoResult.Created, metadata.CreatedDataResult{
OriginIndex: int64(attrIdx),
ID: id,
})
}
```
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: be0592b1ce5c636f005e3ceb97b2cedc4b3bf490
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.