News for hackers. Stuff that matters.
Re:Introduction to Golang by Dewie on Sunday August 18, 2013 @05:22PM (#6234292)
Does it only throw a compiler error if you use 0 as a constant? Let's say you have a function that returns an int; does it force you to check if that int is non-zero before using it in division?
Re:Introduction to Golang by chimeracoder on Sunday August 18, 2013 @06:06PM (#6234463)
It can only throw a compiler error if you use a 0 literal (or constant), because it cannot determine the runtime value of a variable denominator at compile-time (obviously).

It does not force you to check, but if you wanted to "catch" the "exception" (really, "recover from the panic"), here's how you would do that. Note that this is admittedly a somewhat unidiomatic use of recover(): http://play.golang.org/p/dAQ01dus9Y