find exported but unused values in a Go project
A small tool used for a simple cleanups of Go projects. Finds exported values (functions, structs, variables, etc.) that are never used.
No external dependencies.
# install the binary
go install github.com/tompston/dustat@latest
# or clone the repo and run go run main.go
git clone https://github.com/tompston/dustat.git
note that the path to the go/bin
directory must be in your PATH environment variable
# point to the directory of the Go project (use "." for current directory)
dustat <path-to-dir>
# point to the directory, but do not include certain names
dustat --ignore=MyFuncName,MyStructName <path-to-dir>
# clone a big example project locally to a tmp dir
git clone [email protected]:ethereum/go-ethereum.git tmp/go-eth
go run main.go ./tmp/go-eth
## Snippet of the output
...
37 Stacks (tmp/go-eth/internal/debug/api.go:192:18)
37 NewPendingTransactions (tmp/go-eth/eth/filters/api.go:164:23)
39 DumpBlock (tmp/go-eth/eth/api_debug.go:50:22)
49 Resend (tmp/go-eth/internal/ethapi/api.go:1645:28)
57 GetBlobsV2 (tmp/go-eth/eth/catalyst/api.go:526:26)
58 GetAccessibleState (tmp/go-eth/eth/api_debug.go:364:22)
61 IntermediateRoots (tmp/go-eth/eth/tracers/api.go:508:17)
62 AccountRange (tmp/go-eth/eth/api_debug.go:136:22)
70 Syslog (tmp/go-eth/metrics/syslog.go:14:6)
========================================================
Total Unused Lines: 3175, Declarations: 571