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

rafikmajidov/sm-api: daemons/rabbitmq_consumer.go; 40 LoC

Open
#7,377 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 [rafikmajidov/sm-api](https://www.github.com/rafikmajidov/sm-api) at [daemons/rabbitmq_consumer.go](https://github.com/rafikmajidov/sm-api/blob/52355669ccfbef9c17cdf35c3188b6c5d964d3ad/daemons/rabbitmq_consumer.go#L144-L183)

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 d at line 155 may start a goroutine

[Click here to see the code in its original context.](https://github.com/rafikmajidov/sm-api/blob/52355669ccfbef9c17cdf35c3188b6c5d964d3ad/daemons/rabbitmq_consumer.go#L144-L183)

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

```go
for d := range msgs {
var task ellimango.RabbitmqTask
err = json.Unmarshal(d.Body, &task)
if err != nil {
log.Println("Json unmarshall error", err)
} else {
// create switch from task.SyncAction
// depending on action do different actions
switch task.SyncAction {
case MAP_PDE_USER_AGENT:
// send user agent to edge elliman
go sendUserAgentToEdgeElliman(&task, &user, &agent, ch, &q, &d)

case MOD_PDE_USER:
// send user to edge elliman
go sendUserToEdgeElliman(&task, &user, &agent, ch, &q, &d)

case ADD_SVD_APT:
// send user saved listing to edge elliman
go sendSavedApartmentToEdgeElliman(&task, &folder, ch, &q, &d)

case REDIS_UPD_USR_LSTS:
// get user listings from oracle and update redis
go redisUpdateUserListings(&task, &userListing, ch, &q, &d)

case REDIS_UPD_USR:
// get user from oracle and update redis
go redisUpdateUser(&task, &user, ch, &q, &d)

case MEMB_VER_EMAIL:
// make a call to elliman api to send membership verification email to user from elliman
go membershipVerificationEmail(&task, &user, ch, &q, &d)

case DEL_SVD_APT:
// send delete user saved listing to edge elliman
go sendDeleteSavedApartmentToEdgeElliman(&task, &folder, ch, &q, &d)

}
}
}

```

Click here to show extra information the analyzer produced.

```
The following paths through the callgraph could lead to a goroutine:
(sendUserAgentToEdgeElliman, 6) -> (GetByUserId, 1)

```

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: 52355669ccfbef9c17cdf35c3188b6c5d964d3ad

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.