Parquery / gocontracts

A tool for design-by-contract in Go
MIT License
111 stars 7 forks source link

Don't panic, return early #20

Closed elimisteve closed 6 years ago

elimisteve commented 6 years ago

Calling a panic is a no-no and will cause programs to blow up.

Also, unfortunately these checks will slow down programs, but I personally think it's worth it.

mristin commented 6 years ago

Hi @elimisteve, Thanks for raising the issue!

Contracts (as in design-by-contract, not go2 feature) are meant for program correctness, not input validation. When a contract is violated, the program should actually blow up (signalling undefined behavior and a bug) rather than continue to run.

As far as I understood go panics, they are the right tool: https://gobyexample.com/panic

Please re-open if I misunderstood your issue.