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
+5.7k Golang : Reverse by word
+12k Golang : Get user input until a command or receive a word to stop
+7.9k Golang : automatically figure out array length(size) with three dots
+6k Golang : Transform lisp or spinal case to Pascal case example
+26.8k Golang : Read, Write(Create) and Delete Cookie example
+3.9k Golang : A program that contain another program and executes it during run-time
+40.9k Golang : Get hardware information such as disk, memory and CPU usage
+5.6k Golang : Derive cryptographic key from passwords with Argon2
+28.7k Get client IP Address in Go
+24.6k Golang : Get executable name behind process ID example
+7.1k Golang : Find relative luminance or color brightness