Skip to content

Instantly share code, notes, and snippets.

@koral--
Last active October 16, 2018 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koral--/fd784e2ef4c482bf1c4940010193ee55 to your computer and use it in GitHub Desktop.
Save koral--/fd784e2ef4c482bf1c4940010193ee55 to your computer and use it in GitHub Desktop.
Downloading Chuck Norris joke as a plain text
func getRandomJoke(config Config) (string, error) {
request, err := buildJokeRequest(config)
if err != nil {
return "", err
}
response, err := getJoke(request)
if err != nil {
return "", err
}
defer func() {
if err := response.Body.Close(); err != nil {
log.Warnf("Failed to close response body, error: %s", err)
}
}()
return readJokeFromResponse(response)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment