Created
January 20, 2019 15:21
-
-
Save KentaKudo/3a114fa7fd273c41c0970d4184467446 to your computer and use it in GitHub Desktop.
Go Code Snippet: http.Get
This file contains 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
func (c *Client) Get(url string) (string, error) { | |
resp, err := c.cli.Get(url) | |
if err != nil { | |
return "", err | |
} | |
b, err := ioutil.ReadAll(resp.Body) | |
if err != nil { | |
return "", err | |
} | |
return string(b), nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code snippet to read http response body at a time