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

pegnet/PegNetPool: accounting/simulation/esthashrate/main.go; 21 LoC

Open
#13,243 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 [pegnet/PegNetPool](https://www.github.com/pegnet/PegNetPool) at [accounting/simulation/esthashrate/main.go](https://github.com/pegnet/PegNetPool/blob/d667aa7a1c8905a8179a1f0e067509305841f3ac/accounting/simulation/esthashrate/main.go#L61-L81)

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 i used in defer or goroutine at line 66

[Click here to see the code in its original context.](https://github.com/pegnet/PegNetPool/blob/d667aa7a1c8905a8179a1f0e067509305841f3ac/accounting/simulation/esthashrate/main.go#L61-L81)

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

```go
for i := range Vectors {
wg.Add(1)
go func() {
now := time.Now()
sums := accounting.NewShareMap()
computeShares(sums, "key", Vectors[i].TargetHashrate, Vectors[i].Duration)
wl.Lock()
panicErr(writer.Write([]string{
fmt.Sprintf("%d", i),
fmt.Sprintf("%.2f", Vectors[i].TargetHashrate),
fmt.Sprintf("%.2f", Vectors[i].Duration.Seconds()),
fmt.Sprintf("%.2f", sums.Sums["key"].AverageHashrate()),
fmt.Sprintf("%.2f", sums.Sums["key"].LastHashrate()),
fmt.Sprintf("%.2f", sums.Sums["key"].WeightedAverageHashrate()),
fmt.Sprintf("%d", accounting.TargetsKept),
}))
wl.Unlock()
wg.Done()
fmt.Printf("%d finished in %s\n", i, time.Since(now))
}()
}

```

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

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.