Hacker News new | ask | show | jobs
by echoangle 246 days ago
Can’t you include or not include a function that contains a single assert, and depending on the condition, the function call is removed or included?
1 comments

That defeats the point of asserts. Now you have two copies to keep in sync with each other, whereas asserts are inline with the rest of your code and you have one file that can be built with or without them. They could use a separate tool to produce the assert free version, but that adds tooling beyond what Go provides. Nearly every mainstream language allows you to do this without any extra steps, except Go.