Hacker News new | past | comments | ask | show | jobs | submit login

I stronlgy dislike Go's error handling. It is incredibly annoying to add

  if err != nil {
      <do stuff>
  }
after nearly every function call and to have a error as a secondary return type. At least for me it is clunky and annoying and incredibly distracting. If there was at least some syntactic sugar around this I could probably live with it but like this I just don't like using Go.



In google c++ there are two macros which I feel make it look a lot nicer.

  ASSIGN_AND_RETURN(auto var, status_or);
And

  RETURN_IF_ERROR(status);

Which are just more ergonomic with the drawback of being macros.


This works for me.

if res, err := doSomething(); err == nil { return nil, err }

no point in continuing with a null object anyway




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: