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
+7.6k Golang : Process json data with Jason package
+11k Golang : Sieve of Eratosthenes algorithm
+7.9k Golang : Command line ticker to show work in progress
+11.8k Golang : Fuzzy string search or approximate string matching example
+5.9k Get website traffic ranking with Similar Web or Alexa
+19.5k Golang : Get RGBA values of each image pixel
+39.9k Golang : Remove dashes(or any character) from string
+10.1k CodeIgniter : Load different view for mobile devices
+8.9k Golang : Gorilla web tool kit schema example
+8.6k PHP : How to parse ElasticSearch JSON ?
+15.2k Golang : How do I get the local IP (non-loopback) address ?
+7.7k Golang : Detect sample rate, channels or latency with PortAudio