Skip to content

Instantly share code, notes, and snippets.

@benbjohnson
Created Jun 12, 2017
Embed
What would you like to do?
func doSomething() error {
f, err := os.Create("foo")
if err != nil {
return err
}
defer f.Close()
if _, err := f.Write([]byte("bar"); err != nil {
return err
}
if err := f.Close(); err != nil {
return err
}
return nil
}
@abonec
Copy link

abonec commented Jan 18, 2019

Why not just return f.Close() instead of if statement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment