github-vet / github-vet/rangeloop-pointer-findings
yzzyx/nm-imap-sync: main.go; 48 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [yzzyx/nm-imap-sync](https://www.github.com/yzzyx/nm-imap-sync) at [main.go](https://github.com/yzzyx/nm-imap-sync/blob/d9d38d69922fde974568764b01680a54f84f0939/main.go#L156-L203)
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 mailbox used in defer or goroutine at line 167
[Click here to see the code in its original context.](https://github.com/yzzyx/nm-imap-sync/blob/d9d38d69922fde974568764b01680a54f84f0939/main.go#L156-L203)
Click here to show the 48 line(s) of Go which triggered the analyzer.
```go
for name, mailbox := range cfg.Mailboxes {
mailbox.DBPath = maildirPath
folderPath := filepath.Join(maildirPath, name)
err = os.MkdirAll(folderPath, 0700)
if err != nil {
panic(err)
}
imapQueue := make(chan sync.Update, 10000)
go func() {
err = syncdb.CheckFolders(ctx, mailbox, folderPath, imapQueue)
if err != nil {
log.Printf("cannot check folders for new tags: %v\n", err)
return
}
close(imapQueue)
}()
h, err := imap.New(folderPath, mailbox)
if err != nil {
log.Printf("cannot initalize new imap connection: %v\n", err)
return
}
progress := progressbar.NewOptions(-1, progressbar.OptionSetDescription("updating server flags"))
for msgUpdate := range imapQueue {
progress.Add(1)
err = h.Update(syncdb, msgUpdate)
if err != nil {
log.Printf("cannot update message on server: %v\n", err)
return
}
}
progress.Finish()
err = h.CheckMessages(ctx, syncdb, *fullScan)
if err != nil {
log.Printf("cannot check for new messages on server: %v\n", err)
return
}
err = h.Close()
if err != nil {
log.Printf("Cannot close imap handler: %v", err)
return
}
}
```
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: d9d38d69922fde974568764b01680a54f84f0939
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.