Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You should be checking errors immediately after they are returned. Once you've checked it, re-use the variable:

  x, err := f(a)
  if err != nil { // probably time to return from the func }
  y, err := g(x) // we have at least 1 new var, so := still works
  if err != nil { // handle }
  x, err = h(y) // since we're re-using both x and err, just use =
I've never appended a number to "err".


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

Search: