Skip to content

Instantly share code, notes, and snippets.

@Komosa
Created July 11, 2016 10:03
Show Gist options
  • Save Komosa/0b671521fa49a3f2f54b16c09419919b to your computer and use it in GitHub Desktop.
Save Komosa/0b671521fa49a3f2f54b16c09419919b to your computer and use it in GitHub Desktop.
error handling in golang tests
func Test(t *testing.T) {
fatalIf := func(err error) {
if err != nil {
t.Fatal(err)
}
}
err := os.MkdirAll(TEST_DATA_DIR, 0700)
fatalIf(err)
// many other err = sth(); fatalIf(err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment