Will It Vibe logoWill It Vibe?
GO-010Low severity-4 points

panic used in library code

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 4 points from that category, once per scan, no matter how many places it turns up.

What it detects

panic() appears in a file that is not main.go and not under a cmd/ directory, so a library function crashes the whole program instead of returning an error the caller can handle. Heuristic: a handful of intentionally-panicking Must-style constructors are a deliberate, accepted exception to this.

Why it matters

panic in a library function hands control of the failure to the Go runtime's unwinding mechanism instead of to the caller: unless every caller up the chain wraps the call in a recover, the whole program crashes, taking down unrelated requests or goroutines with it. A library that returns an error instead lets each caller decide what "failure" means for their situation, which is the norm for reusable Go code; main()/cmd/ entrypoints are the conventional place where crashing on an unrecoverable condition is acceptable.

How to fix it

Change the function to return an error instead of panicking, and update its callers to check and handle that error the way they already handle every other error in the codebase. Reserve panic for truly unrecoverable programmer errors (a nil that must never be nil, an invariant that must never be violated) and for the small set of intentional Must-style constructors where a panic on invalid static configuration is a deliberate, documented API choice.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks