URL Encode a String
·
179 words
·
1 minute read
If you are coming from a PHP background you’re probably very used to functions like urlencode()
and rawurlencode()
. The good news is you can do the same in Go and rather simply too. In the net/url package there’s a QueryEscape
function which accepts a string and will return the string with all the special characters encoded so they can be added to a url safely. An example of is converting the ‘+’ character into %2B
.
|
|
Alternatively, use url.Values for building a longer query
|
|