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
+3.4k Golang : Switch Redis database redis.NewClient
+12k Golang : 2 dimensional array example
+4.1k Golang : Converting individual Jawi alphabet to Rumi(Romanized) alphabet example
+5.3k PHP : Fix Call to undefined function curl_init() error
+6k Golang : How to get capacity of a slice or array?
+14.9k Golang : How to get Unix file descriptor for console and file
+37.1k Upload multiple files with Go
+4.5k Linux/MacOSX : How to symlink a file?
+16.2k Golang : Get IP addresses of a domain name
+4.9k Golang : Experimental Jawi programming language
+10.6k Golang : Removes punctuation or defined delimiter from the user's input
+5.8k Golang : Experimenting with the Rejang script