github-vet / github-vet/rangeloop-pointer-findings
honglimin29/icenter: src/source_controller/coreservice/core/model/classification.go; 48 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/classification.go](https://github.com/honglimin29/icenter/blob/be0592b1ce5c636f005e3ceb97b2cedc4b3bf490/src/source_controller/coreservice/core/model/classification.go#L131-L178)
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 item at line 135 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/classification.go#L131-L178)
Click here to show the 48 line(s) of Go which triggered the analyzer.
```go
for itemIdx, item := range inputParam.Data {
if 0 == len(item.ClassificationID) {
blog.Errorf("request(%s): it is failed to create the model classification, because of the classificationID (%#v) is not set", ctx.ReqID, item.ClassificationID)
addExceptionFunc(int64(itemIdx), ctx.Error.Errorf(common.CCErrCommParamsNeedSet, metadata.ClassFieldClassificationID).(errors.CCErrorCoder), &item)
continue
}
origin, exists, err := m.isExists(ctx, item.ClassificationID, item.Metadata)
if nil != err {
blog.Errorf("request(%s): it is failed to check the classification ID (%s) is exists, error info is %s", ctx.ReqID, item.ClassificationID, err.Error())
addExceptionFunc(int64(itemIdx), err.(errors.CCErrorCoder), &item)
continue
}
if exists {
cond := mongo.NewCondition()
cond.Element(&mongo.Eq{Key: metadata.ClassificationFieldID, Val: origin.ID})
if _, err := m.update(ctx, mapstr.NewFromStruct(item, "field"), cond); nil != err {
blog.Errorf("request(%s): it is failed to update some fields(%#v) of the classification by the condition(%#v), error info is %s", ctx.ReqID, item, cond.ToMapStr(), err.Error())
addExceptionFunc(int64(itemIdx), err.(errors.CCErrorCoder), &item)
continue
}
dataResult.UpdatedCount.Count++
dataResult.Updated = append(dataResult.Updated, metadata.UpdatedDataResult{
OriginIndex: int64(itemIdx),
ID: uint64(origin.ID),
})
continue
}
item.OwnerID = ctx.SupplierAccount
id, err := m.save(ctx, item)
if nil != err {
blog.Errorf("request(%s): it is failed to save the classification(%#v), error info is %s", ctx.ReqID, item, err.Error())
addExceptionFunc(int64(itemIdx), err.(errors.CCErrorCoder), &item)
continue
}
dataResult.CreatedCount.Count++
dataResult.Created = append(dataResult.Created, metadata.CreatedDataResult{
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.