github-vet / github-vet/rangeloop-pointer-findings

jwzl/edgeOn: dgtwin/dtmodule/property.go; 23 LoC

Open
#6,409 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [jwzl/edgeOn](https://www.github.com/jwzl/edgeOn) at [dgtwin/dtmodule/property.go](https://github.com/jwzl/edgeOn/blob/61b44547ee2e01892873682c19353f4452e99f01/dgtwin/dtmodule/property.go#L462-L484)

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 dgTwin at line 482 may start a goroutine

[Click here to see the code in its original context.](https://github.com/jwzl/edgeOn/blob/61b44547ee2e01892873682c19353f4452e99f01/dgtwin/dtmodule/property.go#L462-L484)

Click here to show the 23 line(s) of Go which triggered the analyzer.

```go
for _, dgTwin := range twinMsg.Twins {
twinID := dgTwin.ID
exist := pm.context.DGTwinIsExist(twinID)
if !exist {
// Device has not created yet.
twins := []common.DigitalTwin{dgTwin}
msgContent, err := common.BuildResponseMessage(common.NotFoundCode, "Twin Not found", twins)
if err != nil {
return err
}
pm.context.SendResponseMessage(msg, msgContent)
}else{
v, _ := pm.context.DGTwinList.Load(twinID)
savedTwin, isDgTwinType :=v.(*common.DigitalTwin)
if !isDgTwinType {
return errors.New("invalud digital twin type")
}
if savedTwin == nil {
return errors.New("savedTwin=nil, Unexpected error")
}
return fn(msg, savedTwin, &dgTwin)
}
}

```

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: 61b44547ee2e01892873682c19353f4452e99f01

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.