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

drbig/grabber: main.go; 56 LoC

Open
#10,051 0 comments 0 reactions 0 assignees View on GitHub
fresh medium
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [drbig/grabber](https://www.github.com/drbig/grabber) at [main.go](https://github.com/drbig/grabber/blob/c2a48495b53bdb4b9a771ad6ff4a5a0e0d757bdd/main.go#L98-L153)

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.

> reference to target was used in a composite literal at line 119

[Click here to see the code in its original context.](https://github.com/drbig/grabber/blob/c2a48495b53bdb4b9a771ad6ff4a5a0e0d757bdd/main.go#L98-L153)

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

```go
for _, target := range rules {
startTarget := time.Now()
log.Println("Target:", target.Name)

root, err := filepath.Abs(target.Path)
if err != nil {
log.Fatalln("ERROR", err)
}

if _, err := os.Stat(root); os.IsNotExist(err) {
log.Fatalln("ERROR", err)
}

base, err := url.Parse(target.URL)
if err != nil {
log.Fatalln("ERROR", err)
}

target.Path = root
stats = &Stats{}
job := &Job{
Target: &target,
Rule: target.Do,
URL: base,
}

run.set(true)
addJob(parsers, job, true)
go func(c chan bool) {
wg.Wait()
c <- true

return
}(ctrl)

inner:
for {
select {
case <-ctrl:
break inner
case <-sig:
if run.get() {
log.Println("SIGNAL: Interrupted, graceful exit...")
log.Println("SIGNAL: Another signal will exit now")
run.set(false)
} else {
break loop
}
}
}

log.Printf("Finished target: %s (took %s)\n", target.Name, time.Since(startTarget))
if !stats.isEmpty() {
log.Println("Download statistics:", stats)
}
}

```

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: c2a48495b53bdb4b9a771ad6ff4a5a0e0d757bdd

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.