I am new to Golang world, I just started my new project with Golang, I would like to know the following now,
Is there any built in function for sorting the key value pair, in asc order of key, where key is string, if yes how
I would like to url encode a string with RFC 3986, when I tried with Encode function by, passing argument as urlStr.Query(), its getting encoded but “space” was encoding to ‘+’, I would like to encode to ‘%20’ instead ‘+’ . Dont know whether this is the proper method to use for url encode. Please help me, if there is any other built in function/ solution for url encode with RFC 3986
No. You do this by creating a slice for the keys, adding the keys to the slice, and sorting the slice. It’s about five lines of code.
%20 is a perfectly appropriate way to encode spaces. Possibly you might get away with just replacing %20 with + in the result, although think through if there are cases where this does work due to escaping or similar (I haven’t thought it through).
Regarding the encoding space, I used the function strings.Replace, after encoding. it works. But suppose if there is already a char ‘+’ is there in string, before encoding, then it will be a problem rt?( actually in RFC 3986, ‘+’ should be encoded to ‘%2B’ rt? here in my case after encoding also ‘+’ remains as ‘+’ )
Will there any encoding built in function to encode RFC3986