https://github.com/gostructs/gostructs
Go static analyzer: find unused and duplicate structs
https://github.com/gostructs/gostructs
code-quality dead-code go-struct golang linter static-analysis
Last synced: 11 days ago
JSON representation
Go static analyzer: find unused and duplicate structs
- Host: GitHub
- URL: https://github.com/gostructs/gostructs
- Owner: gostructs
- License: bsd-3-clause
- Created: 2025-12-12T14:46:19.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2025-12-17T18:19:12.000Z (about 1 month ago)
- Last Synced: 2026-01-12T00:48:32.380Z (14 days ago)
- Topics: code-quality, dead-code, go-struct, golang, linter, static-analysis
- Language: Go
- Homepage:
- Size: 1.57 MB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gostructs
Analyze struct declarations in Go code.
## Installation
```
go install github.com/gostructs/gostructs@latest
```
## Usage
```
gostructs ./... # run all analyses
gostructs -u ./... # find unused structs
gostructs -d ./... # find duplicate structs
gostructs ./pkg/... # analyze specific package
```
## Flags
| Flag | Description |
|------|-------------|
| `-u`, `-unused` | Find unused structs |
| `-d`, `-duplicate` | Find duplicate/similar structs |
| `-t`, `-tags` | Validate struct tags |
| `-j`, `-json` | Output in JSON format |
| `-min-score` | Minimum similarity score (0.0-1.0) for `-d` (default: 0.5) |
| `-min-fields` | Minimum fields to consider for `-d` (default: 2) |
| `-v`, `-version` | Print version |
Note: Generated files (`*.pb.go`, `*_gen.go`, `*_generated.go`) are automatically skipped.
## Output
```
path/to/file.go:15:6: struct Foo is unused
```
Exit codes: `0` success, `1` issues found, `2` error.