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

otsuka-kentaro/fsw-copy-go: main.go; 24 LoC

Open
#6,056 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 [otsuka-kentaro/fsw-copy-go](https://www.github.com/otsuka-kentaro/fsw-copy-go) at [main.go](https://github.com/otsuka-kentaro/fsw-copy-go/blob/e9658c048c565f18da6b2aa263e3c8e1b6c26b46/main.go#L185-L208)

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 destBaseDir used in defer or goroutine at line 189

[Click here to see the code in its original context.](https://github.com/otsuka-kentaro/fsw-copy-go/blob/e9658c048c565f18da6b2aa263e3c8e1b6c26b46/main.go#L185-L208)

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

```go
for _, destBaseDir := range destDir {
go func() {
defer wg.Done()

destFilePath := strings.Replace(file, srcBaseDir, destBaseDir, 1)
if info.IsDir() {
// ディレクトリ作成
if err := os.MkdirAll(destFilePath, info.Mode()); err != nil {
log.Println(err)
fmt.Printf("failed to create directory %s\n", destFilePath)
} else {
fmt.Printf("directory %s created\n", destFilePath)
}
} else {
// ファイルコピー
if err := lib.CopyFile(file, destFilePath); err != nil {
log.Println(err)
fmt.Printf("failed to copy file from %s to %s\n", file, destFilePath)
} else {
fmt.Printf("file copied from %s to %s\n", file, destFilePath)
}
}
}()
}

```

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

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.