package main import ( "fmt" "strings" "net/url" ) func main() { q := url.Values{} q.Add("b", "testing") q.Add("a", "hello world") // url.Values will sort keys(alphabet asc) // and encode ' '(blank) to '+', SHOULD replace to '%20' s := strings.ReplaceAll(q.Encode(), "+", "%20") fmt.Println(s) }