Posted Mar 31, 2012 7:56 UTC (Sat) by fdr (subscriber, #57064)
In reply to: Uses by Cyberax
Parent article: Go version 1 released
If one needs to short circuit for a major fault, use panic/recover. Accrue low-level cleanup actions using defer expressions. Done. I had the same problem you describe and asked some Go-people about it, and then pointed me to a module that used that pattern. It works fine, and doesn't even require a large-scale understanding of the code using said pattern.
panic and recover are there to help with major faults and stack unwinding, and return codes for detailed error recovery that, frankly, are mechanically ugly to complete without being in the low-level mechanism near the failure.
The convention is "must" will panic if something goes wrong. must really is lowercase here, because one is not to panic across library boundaries.