Go: Guarding Against Bad Input, One Panic at a Time
Two fixes landed today that both close off crash paths triggered by unexpected input: gofmt's rewrite tool and the encoding/asn1 package's BitString type. Neither issue was new, but both point to the same lesson—unvalidated assumptions about type or length are where Go's standard library tends to break.
Duration: PT2M13S
Episode overview
This episode is a short developer briefing from Go.
It explains recent repository work in plain language.
- Show: Go
- Published: 2026-08-30T13:06:27Z
- Audio duration: PT2M13S
Transcript excerpt
This excerpt keeps the crawler page concise. Listen to the episode or use the RSS feed for the full update.
Good morning. It's August 30th, and today's Go activity is small but points to a clear pattern: defensive coding around edge cases that were previously assumed safe.
Both pull requests today fix crash bugs, and both crashes came from the same root cause—code trusting that a value would have a certain shape, without checking first.
In PR 81231, developer a-njli fixed a long-standing panic in gofmt's rewrite feature, tied to issue 52145. When a rewrite rule used a lowercase wildcard in a spot expecting a concrete node type—like the selector in a selector expression—gofmt would crash with a reflect panic instead of failing gracefully. The fix…
In PR 81235, TurboRx tackled a similar problem in encoding/asn1. The BitString type's At method promises to return zero for an out-of-range index, but it only checked the bit length—not whether the underlying byte slice was actually long enough. That mismatch could cause a runtime panic when BitLength exceeded slice…
The throughline here: both fixes are about honoring documented behavior. Gofmt was supposed to fail on bad rewrite rules, not panic. BitString.At was documented to return zero on bad indices, not crash. In both cases, the code path…
Wha…
Nearby episodes from Go
- Correctness Cleanup Across the Stack
- Type Checker Cleanup and Correctness Fixes
- Hardening the Edges of Networking and Testing
- Correctness Fixes Across the Compiler and Runtime
- Compiler Backend Consolidation and a Landlock Security Fix
- LoongArch Gets Serious Performance Attention
- Weekly Recap - Hardening the Network Stack
- Platform Edge Cases Under the Microscope