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

pkthigh/pkt_activity: src/service/service.go; 20 LoC

Open
#16,179 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 [pkthigh/pkt_activity](https://www.github.com/pkthigh/pkt_activity) at [src/service/service.go](https://github.com/pkthigh/pkt_activity/blob/25cd5b42d21e6670ca862ac1c54edf321f50a64c/src/service/service.go#L182-L201)

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.

> range-loop variable activity used in defer or goroutine at line 186

[Click here to see the code in its original context.](https://github.com/pkthigh/pkt_activity/blob/25cd5b42d21e6670ca862ac1c54edf321f50a64c/src/service/service.go#L182-L201)

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

```go
for _, activity := range srv.activitys {
if activity.Ongoing() {
// 检测当前活动是否下线
go func() {
if time.Unix(int64(activity.Info().Info.OfflineTime), 0).Format("2006-01-02 15:04") == mt {

logger.InfoF("[Regularly Check]: 活动: %v 下线: %v", activity.ID(), mt)
if err := srv.activitys[common.ACTYPE(activity.Type())].OfflineOngoing(); err != nil {
logger.ErrorF("[Regularly Check]: 活动: %v 下线: %v 错误: %v", activity.ID, mt, err)
return
}

time.Sleep(1 * time.Second)
if err := srv.change(); err != nil {
logger.ErrorF("[Regularly Check]: 活动: %v 下线通知: %v 错误: %v", activity.ID, mt, err)
}
}
}()
}
}

```

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: 25cd5b42d21e6670ca862ac1c54edf321f50a64c

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.