On Thu, 28 Mar 2013, suhas kodgire wrote:
>
> I have written a web service in which I send parameters as query string .
> In the program I convert those parameters to url.Values by Query method .
>
> I get all the parameters there when I print them on console , I get
> following result
>
> map[page_number:[1] per_page:[24] filters[min_price]:[0] filters[dogs]:[0]
> filters[cats]:[0]]
>
>
> Now I need to check if parameter contains any fiilters .
>
> One way to do it check for params["filters[min_price]"] ,
> params["filters[dog]"] , params["filters[cat]"] etc with empty (nil)
> condition .
> Is there any way to check this effectively ?
The actual type of url.Values is "map[string][]string". So you can loop over
the keys,
for key, val := range myUrl.Query() {
if strings.IsPrefix("filters", key) {
doFilter(key, val)
}
}
Or something along those lines.
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
golang-nuts...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>
>
--
Scott Lawrence
go version go1.0.3
Linux baidar 3.8.3-2-ARCH #1 SMP PREEMPT Sun Mar 17 13:04:22 CET 2013 x86_64 GNU/Linux