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
+8k Golang : Check from web if Go application is running or not
+10k Golang : Get login name from environment and prompt for password
+8.8k Golang : Find network service name from given port and protocol
+6.6k Golang : Derive cryptographic key from passwords with Argon2
+7.8k Golang : Trim everything onward after a word
+8.5k Golang : Another camera capture GUI application with GTK and OpenCV
+7.1k Nginx : How to block user agent ?
+7.5k Gogland : Single File versus Go Application Run Configurations
+12k Golang : Sort and reverse sort a slice of runes
+15.3k Golang : Find location by IP address and display with Google Map
+11.1k CodeIgniter : How to check if a session exist in PHP?
+5.8k Golang : Markov chains to predict probability of next state example