Created
November 7, 2014 17:05
-
-
Save kyleconroy/44ecda49fccdc859aa1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// write this | |
import ( | |
"encoding/json" | |
"net/http" | |
) | |
func foo() (int, err) { | |
resp := try(resp.Get("http://api.stripe.com")) | |
body := try(ioutil.ReadAll(resp.Body)) | |
return len(body), nil | |
} | |
// to this | |
import ( | |
"encoding/json" | |
"net/http" | |
) | |
func foo() (int, err) { | |
resp, err := resp.Get("http://api.stripe.com") | |
if err != nil { | |
return 0, err | |
} | |
body, err := ioutil.ReadAll(resp.Body) | |
if err != nil { | |
return 0, err | |
} | |
return len(body), nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment