News for hackers. Stuff that matters.
Re:Convert curl commands to Go code by kasey_junk on Wednesday February 10, 2016 @05:57PM (#11076873)
One of the (possibly contentious) principles in Golang is that each error needs to be addressed individually with an appropriate response to the particular case in question.

In practice most Golang errors are handled either:

1) Ignored

2) Logged and swallowed

3) Returned at the point it happened.

4) Fatally exits the program.

One of the "features" of the errors as return codes is that you don't get surprising results that come from the goto style jumps that happen with something like exceptions (unrolling state, etc).

Re:Convert curl commands to Go code by tptacek on Wednesday February 10, 2016 @07:23PM (#11077343)
That's not really true. It's certainly an idiom in Golang to handle errors individually, but it's not a principle.

The principal is that errors are values like everything else, and you can write code to handle them however you'd like. See, for instance, the "write" example in this post:

https://blog.golang.org/errors-are-values

There are libraries that people use (sqlx might be an example) that are more like that example than the if-error-return stuff here.

Re:Convert curl commands to Go code by kasey_junk on Wednesday February 10, 2016 @08:31PM (#11077654)
>The language's design and conventions encourage you to explicitly check for errors where they occur (as distinct from the convention in other languages of throwing exceptions and sometimes catching them)

http://blog.golang.org/error-handling-and-go

Re:Convert curl commands to Go code by vessenes on Wednesday February 10, 2016 @08:06PM (#11077546)
Just to expand on this for other's benefit, it's not idiomatic for errors to result in panics; in general Go code will soldier on. If you're expecting code with trouble to 'throw' an exception and puke, you're in for a bad time, or at least a confusing one.