github-vet / github-vet/rangeloop-pointer-findings
xatasan/kagami: file.go; 36 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [xatasan/kagami](https://www.github.com/xatasan/kagami) at [file.go](https://github.com/xatasan/kagami/blob/a598500ce6185e8c066471811a95c2b922b62efe/file.go#L57-L92)
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 T used in defer or goroutine at line 74
[Click here to see the code in its original context.](https://github.com/xatasan/kagami/blob/a598500ce6185e8c066471811a95c2b922b62efe/file.go#L57-L92)
Click here to show the 36 line(s) of Go which triggered the analyzer.
```go
for T := range write {
t_id := T[0].PostNumber
debugL("[sf/%05d] Saving thread %d\n", getGID(), t_id)
f, err := os.Create(fmt.Sprintf("%s%d.html", t_dir, t_id))
if err != nil {
log.Fatal(err)
}
pr, pw := io.Pipe()
defer pr.Close()
go func() {
err = t.Lookup("thread.tmpl").Execute(pw, struct {
F Post // head of the thread
T Thread // thread without head
B string // board name
N template.HTML // mirror name
U time.Time // time generated
}{T[0], T[1:], board, template.HTML(name), time.Now()})
if err != nil {
log.Fatal(err)
}
debugL("[sf/%05d] Generated thread %d\n", getGID(), t_id)
pw.Close()
}()
m.Minify("text/html", f, pr)
f.Close()
for _, post := range T {
for _, file := range post.Files {
dl <- file
}
}
debugL("[sf/%05d] Minified thread %d\n", getGID(), t_id)
}
```
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: a598500ce6185e8c066471811a95c2b922b62efe
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with file.go lines 57-92 at commit a598500ce6185e8c066471811a95c2b922b62efe, focusing on the range loop, defer, and goroutine identified by the analyzer. Review whether the reported range-loop capture is an actual bug or intended behavior. Done means leaving the requested Bug, Mitigated, or Desirable Behavior reaction after that review.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100