Skip to content

Instantly share code, notes, and snippets.

@koral--
Created October 16, 2018 15:48
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--/11230db4f2ee5e3eb0ebf7bcfd556057 to your computer and use it in GitHub Desktop.
Save koral--/11230db4f2ee5e3eb0ebf7bcfd556057 to your computer and use it in GitHub Desktop.
HTTP request with timeout in Go
func getJoke(request *http.Request) (*http.Response, error) {
client := &http.Client{}
client.Timeout = 20 * time.Second
return client.Do(request)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment