Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/karamaru-alpha/copyloopvar
copyloopvar is a linter detects places where loop variables are copied.
https://github.com/karamaru-alpha/copyloopvar
Last synced: 3 months ago
JSON representation
copyloopvar is a linter detects places where loop variables are copied.
- Host: GitHub
- URL: https://github.com/karamaru-alpha/copyloopvar
- Owner: karamaru-alpha
- License: mit
- Created: 2024-02-13T20:32:10.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-04-09T14:07:57.000Z (10 months ago)
- Last Synced: 2024-06-21T15:25:15.120Z (7 months ago)
- Language: Go
- Size: 27.3 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ccamel - karamaru-alpha/copyloopvar - copyloopvar is a linter detects places where loop variables are copied. (Go)
README
# copyloopvar
copyloopvar is a linter detects places where loop variables are copied.
cf. [Fixing For Loops in Go 1.22](https://go.dev/blog/loopvar-preview)
## Example
```go
for i, v := range []int{1, 2, 3} {
i := i // The copy of the 'for' variable "i" can be deleted (Go 1.22+)
v := v // The copy of the 'for' variable "v" can be deleted (Go 1.22+)
_, _ = i, v
}for i := 1; i <= 3; i++ {
i := i // The copy of the 'for' variable "i" can be deleted (Go 1.22+)
_ = i
}
```## Install
```bash
go install github.com/karamaru-alpha/copyloopvar/cmd/copyloopvar@latest
go vet -vettool=`which copyloopvar` ./...
```