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
+19.8k Golang : For loop continue,break and range
+30.6k Golang : Validate email address with regular expression
+6.5k Golang : Convert source code to assembly language
+8.6k Golang : How to check if a website is served via HTTPS
+8.9k Golang : Edge detection with Sobel method
+7.9k Golang : Apply Histogram Equalization to color images
+26.5k Golang : Decode/unmarshal unknown JSON data type with map[string]interface
+9.4k Golang : Simple File Server
+7.1k Golang : Auto-generate reply email with text/template package
+12.6k Golang : Fix image: unknown format error
+7.8k Golang : Heap sort example