Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You could, but then when you get an error, you'll see the file and line number of the assert function rather than the code that actually produced the error.


The runtime package allows you to grab the current trace, you can just pop the last frame off and print that.


True. The only other challenge is that in production software you rarely want to call panic()


As another comment mentioned you can just use build tags to make assert a no-op in release builds




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: