News for hackers. Stuff that matters.
Re:Go 1.2 by nemothekid on Friday November 29, 2013 @05:09PM (#6821213)
I agree with the panic sentiment. I almost never know when to actually use panic or to just return an error code. My guess is the reason panic is never used is because its "bad go" for a panic to leave your library/package.

http://golang.org/doc/effective_go.html#panic

Re:Go 1.2 by ansible on Friday November 29, 2013 @07:07PM (#6821604)
Generally speaking, you ought to use error instead of panic. The only time panic is appropriate is when the program really ought to just crash.

For example, I'm writing a small program to update a database. If the DB connection can't be opened, the program can't do anything useful, so it can just exit with an error.

Any library should just use error.

Re:Go 1.2 by voltagex_ on Sunday December 01, 2013 @06:45PM (#6830074)
Why isn't lack of DB connection a panic condition?
Re:Go 1.2 by ansible on Monday December 02, 2013 @05:25PM (#6837029)
Why isn't lack of DB connection a panic condition?

It is a panic condition... I could have chosen my words better. That's what I meant by the program exiting.

Re:Go 1.2 by codygman on Monday December 02, 2013 @02:01AM (#6832223)
So that the user of said library can decide how to handle a failed DB connection?