Hacker News new | past | comments | ask | show | jobs | submit login

What do you mean by “code like that”?

If you mean the code that never wraps anything and just does “return err”, then it could actually be better off using panics. In fact, it's documented in Effective Go[1]. If all you return in your API is a simple opaque “shit's broken, yo” error, then it is a perfectly valid approach to use panics. As long as they are in your package's insides, and as long as you return an error on the external border of your API instead of making users handle your panics.

[1] https://golang.org/doc/effective_go.html#recover

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact