Hacker News new | ask | show | jobs
by mweibel 1908 days ago
you could use an `else` clause for the scope:

  if foo, err := doThing(bar); err != nil {
    // handle error  
  } else {
    // handle foo
  }
but most don't use that form and just do the call outside:

  foo, err := doThing(bar)
  if err != nil {
    // handle error  
  }
1 comments

or pass doThing as a function parameter

https://play.golang.org/p/4PoK6EZc4W9