Golang : Query string with space symbol %20 in between
Problem :
You want to form URL that looks like this :
https://example.com/query?keyword="golang lookup"
but your final URL looks like this :
https://example.com/query?keyword="golang%20lookup"
How to get rid the %20
sign ?
Solution :
Use url.QueryEscape() function to escapes the string so it can be safely placed inside a URL query. For example :
func TagSearch(tag string) string {
return fmt.Sprintf("https://example.com/query?keyword=%s", url.QueryEscape(tag))
}
References :
See also : Golang : Get query string value on a POST request
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+4.3k Javascript : How to refresh page with JQuery ?
+12.6k Golang : Get URI segments by number and assign as variable example
+13.5k Golang : Loop each day of the current month example
+5.3k Golang : Reverse by word
+8k Golang : Turn string or text file into slice example
+4.6k Fontello : How to load and use fonts?
+4.7k Golang : Detect face in uploaded photo like GPlus
+4.6k Golang & Javascript : How to save cropped image to file on server
+9.1k Golang : Calculate Relative Strength Index(RSI) example
+7.8k Golang : Changing a RGBA image number of channels with OpenCV
+16.9k Golang : Measure http.Get() execution time