Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sanposhiho/wastedassign
Go Linter: finds wasted assignment statements 🗑
https://github.com/sanposhiho/wastedassign
analyzer go golang staticanalysis
Last synced: 11 days ago
JSON representation
Go Linter: finds wasted assignment statements 🗑
- Host: GitHub
- URL: https://github.com/sanposhiho/wastedassign
- Owner: sanposhiho
- License: mit
- Created: 2020-09-02T18:36:51.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-25T02:19:30.000Z (over 2 years ago)
- Last Synced: 2024-08-01T13:32:22.042Z (3 months ago)
- Topics: analyzer, go, golang, staticanalysis
- Language: Go
- Homepage:
- Size: 55.7 KB
- Stars: 35
- Watchers: 2
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-ccamel - sanposhiho/wastedassign - Go Linter: finds wasted assignment statements 🗑 (Go)
README
# wastedassign
`wastedassign` finds wasted assignment statementsfound the value ...
- reassigned, but never used afterward
- reassigned, but reassigned without using the value## Example
```go
package mainimport "fmt"
func f() int {
a := 0
b := 0
fmt.Print(a)
fmt.Print(b)
a = 1 // This reassignment is wasted, because never used afterwards. Wastedassign find thisb = 1 // This reassignment is wasted, because reassigned without use this value. Wastedassign find this
b = 2
fmt.Print(b)
return 1 + 2
}
``````bash
$ go vet -vettool=`which wastedassign` sample.go
# command-line-arguments
./sample.go:10:2: assigned to a, but never used afterwards
./sample.go:12:2: assigned to b, but reassigned without using the value
```## Installation
### Go version < 1.16
```
go get -u github.com/sanposhiho/wastedassign/v2/cmd/wastedassign
```### Go version 1.16+
```
go install github.com/sanposhiho/wastedassign/v2/cmd/wastedassign@latest
```## Usage
```
# in your projectgo vet -vettool=`which wastedassign` ./...
```And, you can use wastedassign in [golangci-lint](https://github.com/golangci/golangci-lint).
## Contribution
I am waiting for your contribution :D
Feel free to create an issue or a PR!
### Run test
```
go test
```