https://github.com/ldemailly/panic-linter
Go linter that flags panic() call that don't have a comment explaining why panic
https://github.com/ldemailly/panic-linter
go golang golang-linter linter
Last synced: 7 months ago
JSON representation
Go linter that flags panic() call that don't have a comment explaining why panic
- Host: GitHub
- URL: https://github.com/ldemailly/panic-linter
- Owner: ldemailly
- License: apache-2.0
- Created: 2024-10-07T23:47:09.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-11-12T23:57:41.000Z (8 months ago)
- Last Synced: 2024-11-13T00:30:41.410Z (8 months ago)
- Topics: go, golang, golang-linter, linter
- Language: Go
- Homepage:
- Size: 30.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://goreportcard.com/report/github.com/ldemailly/panic-linter)
[](https://pkg.go.dev/github.com/ldemailly/panic-linter)
[](https://codecov.io/gh/ldemailly/panic-linter)
[](https://github.com/ldemailly/panic-linter/actions/workflows/include.yml)# panic-linter
`paniccheck` is a golang linter that flags panic() call that don't have a comment explaining why panic.https://go.dev/wiki/CodeReviewComments#dont-panic
## Why?
panic should only be used very sparingly, for catching bugs basically, and thus deserve a comment to confirm that that's indeed the case
bad:
```go
panic("catch this")
```good:
```go
panic(fmt.Sprintf("bug: unexpected input=%v because...", input)) // Shouldn't happen unless we have bug
```