Skip to content

Instantly share code, notes, and snippets.

@ivanauliaa
Last active December 18, 2021 10:22
Show Gist options
  • Save ivanauliaa/420cc1375dd3f40d15af191366726bee to your computer and use it in GitHub Desktop.
Save ivanauliaa/420cc1375dd3f40d15af191366726bee to your computer and use it in GitHub Desktop.
Construct query params in GET request (GO)
request, err := http.NewRequest("GET", baseUrl+"/user", nil)
if err != nil {
return data, err
}
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
q := request.URL.Query()
q.Add("id", ID)
request.URL.RawQuery = q.Encode()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment