Re:Alan Donovan and Brian Kernighan Answer Questions on Go
by ngrilly on Friday November 20, 2015 @10:57AM
(#10601821)
How many lines of Go have you written before writing this?
In Go, as in Java with checked exceptions, the compiler forces the programmer to handle the error.
Using _ in Go is not idiomatic. It's the exact equivalent of using a try/catch block with nothing in the catch block in Java.
Re:Alan Donovan and Brian Kernighan Answer Questions on Go
by pcwalton on Friday November 20, 2015 @02:25PM
(#10603256)
If you call a function that returns nothing but an error, Go does not force you to acknowledge the error's existence and will silently allow you to drop it.
Re:Alan Donovan and Brian Kernighan Answer Questions on Go
by Karunamon on Friday November 20, 2015 @11:24AM
(#10602006)
Or not checking for the exception at all. Certain classes of errors can and should be allowed to pass up the call stack and cause your program to die (something strange that I wasn't expecting and don't know how to handle happened, and now I'm in a bad state - safer to exit)
Now if you choose to handle this stupidly, that's entirely your fault, but at least the compiler did its jobs by forcing you to think about the error case.
In Go, the compiler doesn't enforce anything.