There is a very simple way provided by the golang net/url
package itself.
Modify your string to make it a URL with text := "method://abc.xyz/A=B&C=D&E=F";
request parameters text := "method://abc.xyz/A=B&C=D&E=F";
Now just pass this line to the Parse
function provided by net/url
.
import ( netURL "net/url" )
u, err := netURL.Parse(textURL) if err != nil { log.Fatal(err) }
Now u.Query()
will return you a map containing the parameters of your query. This will also work for complex types.
source share