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
+20.2k PHP : Convert(cast) int to double/float
+8k Golang : How to check variable or object type during runtime?
+25.6k Golang : Get executable name behind process ID example
+14.2k Golang : Rename directory
+9.6k Golang : Detect number of faces or vehicles in a photo
+10.5k PHP : Convert(cast) bigInt to string
+11.9k Golang : Validate email address
+29.8k Get client IP Address in Go
+19.7k Golang : Count number of digits from given integer value
+34.8k Golang : Strip slashes from string example
+22.4k Golang : Test file read write permission example
+22.1k Golang : Set and Get HTTP request headers example