Skip to content

Instantly share code, notes, and snippets.

@YanhaoYang
Created February 9, 2017 07:46
Show Gist options
  • Save YanhaoYang/10be4551632680cee1c40fb441ea8abe to your computer and use it in GitHub Desktop.
Save YanhaoYang/10be4551632680cee1c40fb441ea8abe to your computer and use it in GitHub Desktop.
Solution: error return value not checked (defer response.Body.Close())
// Closable wraps Close() method
type Closable interface {
Close() error
}
func closeIt(obj Closable) {
err := obj.Close()
if err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment