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
+17.9k Golang : Put UTF8 text on OpenCV video capture image frame
+7.6k Golang : How to execute code at certain day, hour and minute?
+30.3k Golang : Generate random string
+15k JavaScript/JQuery : Detect or intercept enter key pressed example
+12.9k Golang : Calculate elapsed years or months since a date
+9.2k Golang : How to get garbage collection data?
+13.9k Golang : concatenate(combine) strings
+13.3k Golang : Read XML elements data with xml.CharData example
+6.6k Golang : Reverse by word
+11k Google Maps URL parameters configuration
+25.1k Golang : Convert uint value to string type