Last active
December 18, 2021 10:22
-
-
Save ivanauliaa/420cc1375dd3f40d15af191366726bee to your computer and use it in GitHub Desktop.
Construct query params in GET request (GO)
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
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