github-vet / github-vet/rangeloop-pointer-findings
zdarovich/einvoice: services/documentService.go; 17 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [zdarovich/einvoice](https://www.github.com/zdarovich/einvoice) at [services/documentService.go](https://github.com/zdarovich/einvoice/blob/032c1573630b73bca0998eee60f5eecf7bd34ee4/services/documentService.go#L49-L65)
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 doc is reassigned at line 58
[Click here to see the code in its original context.](https://github.com/zdarovich/einvoice/blob/032c1573630b73bca0998eee60f5eecf7bd34ee4/services/documentService.go#L49-L65)
Click here to show the 17 line(s) of Go which triggered the analyzer.
```go
for _, doc := range docs {
logrus.Trace(fmt.Sprintf("generate hash of docID %d", doc.ID))
docByte, err := json.Marshal(doc)
if err != nil {
logrus.Error(err)
}
hash := sha256.Sum256(docByte)
hashBase64 := base64.StdEncoding.EncodeToString(hash[:])
docHash := new(DocumentHash)
docHash.doc = &doc
docHash.hash = hashBase64
select {
case <-done:
return
case receiveStream <- *docHash:
}
}
```
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: 032c1573630b73bca0998eee60f5eecf7bd34ee4
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with services/documentService.go at lines 49-65 in commit 032c1573630b73bca0998eee60f5eecf7bd34ee4 and inspect how the range-loop variable is referenced through DocumentHash. Determine whether the analyzer's reported reassignment creates an actual bug, then mark the finding with the appropriate reaction: Bug, Mitigated, or Desirable Behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100