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
+48.7k Golang : Upload file from web browser to server
+11.3k Golang : Calculate Relative Strength Index(RSI) example
+16k Golang : ROT47 (Caesar cipher by 47 characters) example
+17.7k Convert JSON to CSV in Golang
+20k Golang : How to get time from unix nano example
+8.5k Your page has meta tags in the body instead of the head
+10.9k PHP : Convert(cast) bigInt to string
+8.9k Golang : On lambda, anonymous, inline functions and function literals
+9.1k Golang : Capture text return from exec function example
+20.8k Android Studio : AlertDialog and EditText to get user string input example
+19.5k Golang : Fix cannot download, $GOPATH not set error
+27.5k Golang : Convert CSV data to JSON format and save to file