From c1910bf6b68640bc6b09c13426de85b74e4c81e6 Mon Sep 17 00:00:00 2001 From: Adrian Gallagher Date: Wed, 21 Oct 2015 10:14:34 +1100 Subject: [PATCH] Added common EncodeURLValues function. --- common.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common.go b/common.go index 3a807dee..3fcc2e70 100644 --- a/common.go +++ b/common.go @@ -16,6 +16,7 @@ import ( "log" "math" "net/http" + "net/url" "strings" ) @@ -259,3 +260,11 @@ func JSONDecode(data []byte, to interface{}) error { return nil } + +func EncodeURLValues(url string, values url.Values) string { + path := url + if len(values) > 0 { + path += "?" + values.Encode() + } + return path +}