Skip to content

Instantly share code, notes, and snippets.

@kendellfab
Created August 26, 2013 14:27
Show Gist options
  • Save kendellfab/6341981 to your computer and use it in GitHub Desktop.
Save kendellfab/6341981 to your computer and use it in GitHub Desktop.
Golang Example for adding custom headers to a request.
client := &http.Client{]
req, err := http.NewRequest("POST", "http://example.com", bytes.NewReader(postData))
req.Header.Add("User-Agent", "myClient")
resp, err := client.Do(req)
defer resp.Body.Close()
@R4wm
Copy link

R4wm commented Sep 13, 2016

http.Client right square bracket should be a right curly brace
https://gist.github.com/R4wm/405eb358e9383dc8457a55025d0a8d68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment