github-vet / github-vet/rangeloop-pointer-findings
Azure/azure-storage-azcopy: testSuite/cmd/clean.go; 29 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [Azure/azure-storage-azcopy](https://www.github.com/Azure/azure-storage-azcopy) at [testSuite/cmd/clean.go](https://github.com/Azure/azure-storage-azcopy/blob/a3d0fe3d607255cf9fdc1ef37b15e780ec04c4ca/testSuite/cmd/clean.go#L441-L469)
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 bucket used in defer or goroutine at line 453
[Click here to see the code in its original context.](https://github.com/Azure/azure-storage-azcopy/blob/a3d0fe3d607255cf9fdc1ef37b15e780ec04c4ca/testSuite/cmd/clean.go#L441-L469)
Click here to show the 29 line(s) of Go which triggered the analyzer.
```go
for _, bucket := range buckets {
// Remove all the things in bucket with prefix
if !strings.HasPrefix(bucket.Name, "s2scopybucket") {
continue // skip buckets not created by s2s copy testings.
}
objectsCh := make(chan string)
go func() {
defer close(objectsCh)
// List all objects from a bucket-name with a matching prefix.
for object := range s3Client.ListObjectsV2(bucket.Name, "", true, context.Background().Done()) {
if object.Err != nil {
fmt.Printf("error listing the objects from bucket %q, %v\n", bucket.Name, err)
return
}
objectsCh <- object.Key
}
}()
// List bucket, and delete all the objects in the bucket
_ = s3Client.RemoveObjects(bucket.Name, objectsCh)
// Remove the bucket.
if err := s3Client.RemoveBucket(bucket.Name); err != nil {
fmt.Printf("error deleting the bucket %q from account, %v\n", bucket.Name, err)
}
}
```
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: a3d0fe3d607255cf9fdc1ef37b15e780ec04c4ca
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.