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

hrfee/jfa-go: api.go; 30 LoC

Open
#8,699 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 [hrfee/jfa-go](https://www.github.com/hrfee/jfa-go) at [api.go](https://github.com/hrfee/jfa-go/blob/91252730366ea34a9feb2a7936b9e0fc14a1beb2/api.go#L111-L140)

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 code used in defer or goroutine at line 125

[Click here to see the code in its original context.](https://github.com/hrfee/jfa-go/blob/91252730366ea34a9feb2a7936b9e0fc14a1beb2/api.go#L111-L140)

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

```go
for code, data := range app.storage.invites {
expiry := data.ValidTill
if !currentTime.After(expiry) {
continue
}
app.debug.Printf("Housekeeping: Deleting old invite %s", code)
notify := data.Notify
if app.config.Section("notifications").Key("enabled").MustBool(false) && len(notify) != 0 {
app.debug.Printf("%s: Expiry notification", code)
for address, settings := range notify {
if !settings["notify-expiry"] {
continue
}
go func() {
msg, err := app.email.constructExpiry(code, data, app)
if err != nil {
app.err.Printf("%s: Failed to construct expiry notification", code)
app.debug.Printf("Error: %s", err)
} else if err := app.email.send(address, msg); err != nil {
app.err.Printf("%s: Failed to send expiry notification", code)
app.debug.Printf("Error: %s", err)
} else {
app.info.Printf("Sent expiry notification to %s", address)
}
}()
}
}
changed = true
delete(app.storage.invites, code)
}

```

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: 91252730366ea34a9feb2a7936b9e0fc14a1beb2

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.