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

bamchoh/pollydent: example/example.go; 32 LoC

Open
#17,843 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 [bamchoh/pollydent](https://www.github.com/bamchoh/pollydent) at [example/example.go](https://github.com/bamchoh/pollydent/blob/3d3c0c16fc5008dda1aa59ab8ea0c84945ccc779/example/example.go#L37-L68)

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 p used in defer or goroutine at line 62

[Click here to see the code in its original context.](https://github.com/bamchoh/pollydent/blob/3d3c0c16fc5008dda1aa59ab8ea0c84945ccc779/example/example.go#L37-L68)

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

```go
for _, p := range pollydents {
// Example 1
// Read Aloud Example
err = p.ReadAloud("こんにちは世界")
if err != nil {
log.Fatal(err)
}

// Example 2
// SendToPolly / Play Example
params := []polly.SpeechParams{
polly.SpeechParams{"こんばんわ世界", "Mizuki", 100},
polly.SpeechParams{"おはようございます世界", "Mizuki", 200},
polly.SpeechParams{"Hello World", "Joey", 100},
}

var strm io.Reader
var wg sync.WaitGroup
for _, param := range params {
wg.Add(1)
strm, err = p.SendToServer(param)
if err != nil {
log.Fatal(err)
}
go func(strm2 io.Reader) {
p.Play(strm2)
wg.Done()
}(strm)
}

wg.Wait()
}

```

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: 3d3c0c16fc5008dda1aa59ab8ea0c84945ccc779

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.