github-vet / github-vet/rangeloop-pointer-findings
WUMUXIAN/aws-slack-bot: jobs/slack_job.go; 50 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [WUMUXIAN/aws-slack-bot](https://www.github.com/WUMUXIAN/aws-slack-bot) at [jobs/slack_job.go](https://github.com/WUMUXIAN/aws-slack-bot/blob/fc939245211eb85a42cd4ea81744c5fa4f820333/jobs/slack_job.go#L85-L134)
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 usage used in defer or goroutine at line 87
[Click here to see the code in its original context.](https://github.com/WUMUXIAN/aws-slack-bot/blob/fc939245211eb85a42cd4ea81744c5fa4f820333/jobs/slack_job.go#L85-L134)
Click here to show the 50 line(s) of Go which triggered the analyzer.
```go
for region, usage := range o.regionUsage {
go func() {
usage.ec2UsageChan <- stats.GetEC2Usage(usage.Sess)
}()
now := time.Now().UTC()
currentYear, currentMonth, _ := now.Date()
currentLocation := now.Location()
firstDayOfMonth := time.Date(currentYear, currentMonth, 1, 0, 0, 0, 0, currentLocation)
lastDayOfMonth := firstDayOfMonth.AddDate(0, 1, 0).Add(-time.Second)
go func() {
usage.s3UsageChan <- stats.GetS3Usage(usage.Sess, firstDayOfMonth, lastDayOfMonth)
}()
go func() {
usage.cloudFrontUsageChan <- stats.GetCloudFrontUsage(usage.Sess, firstDayOfMonth, lastDayOfMonth)
}()
go func() {
usage.rdsUsageChan <- stats.GetRDSUsage(usage.Sess, firstDayOfMonth, lastDayOfMonth)
}()
go func() {
usage.elasticacheUsageChan <- stats.GetElasticacheUsage(usage.Sess, firstDayOfMonth, lastDayOfMonth)
}()
go func() {
// fmt.Println("Gather accumulated estimated billing for this month", firstDayOfMonth, lastDayOfMonth)
month, average := stats.GetEstimatedBilling(usage.Sess, firstDayOfMonth, lastDayOfMonth)
usage.billingEstimationCurrentMonthChan <- []float64{month, average}
}()
firstDayOfLastMonth := firstDayOfMonth.AddDate(0, -1, 0)
lastDayOfLastMonth := firstDayOfLastMonth.AddDate(0, 1, 0).Add(-time.Second)
go func() {
// fmt.Println("Gather accumulated estimated billing for last month", firstDayOfLastMonth, lastDayOfLastMonth)
month, average := stats.GetEstimatedBilling(usage.Sess, firstDayOfLastMonth, lastDayOfLastMonth)
usage.billingEstimationLastMonthChan <- []float64{month, average}
}()
ec2UsageMap[region] = <-usage.ec2UsageChan
s3UsageMap[region] = <-usage.s3UsageChan
cloudFrontUsageMap[region] = <-usage.cloudFrontUsageChan
rdsUsageMap[region] = <-usage.rdsUsageChan
elasticacheUsageMap[region] = <-usage.elasticacheUsageChan
billingEstimation := <-usage.billingEstimationCurrentMonthChan
billingEstimationCurrentMonth[0] += billingEstimation[0]
billingEstimationCurrentMonth[1] += billingEstimation[1]
billingEstimation = <-usage.billingEstimationLastMonthChan
billingEstimationLastMonth[0] += billingEstimation[0]
billingEstimationLastMonth[1] += billingEstimation[1]
}
```
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: fc939245211eb85a42cd4ea81744c5fa4f820333
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.