The wiki code is correct. r.URL.Path should begin with a slash, always.

I'm not sure what you're doing that is different. That wiki code is tested,
though.

On 19 October 2016 at 21:15, KIDJourney <kingdeadfis...@gmail.com> wrote:

> Hi every one .
>     I am new guy to golang.
>     When I am reading golang wiki about web development I find a small
> issue in the article, Here is the wiki page i read https://golang.org/doc/
> articles/wiki/#tmp_11 .
>     At the section of Validation, it creates a regexp to valid and get the
> file name.
>
>
> var validPath = regexp.MustCompile("^/(edit|save|view)/([a-zA-Z0-9]+)$")
> // Then used in
> title := validPath.FindStringSubmatch(r.URL.Path)
>
>     But this regex expression is wrong, it can't get the correct file name
> because the path doesn't start with '/'.
>     I think the correct  regex expression should be
>
> var validPath = regexp.MustCompile("/(edit|save|view)/([a-zA-Z0-9]+)$")
>
> and it works well for me .
>
>     is the wiki incorrect or just i did something wrong ?
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to