Gorilla/Mux Reverse mapping URL

I’m new in development. Now trying to learn gorilla/mux router. The question is about reversed urls. In gorilla/mux I know we name them with .Name() method and access with .Url(). Could someone explain real use case of reserved URL’s(Reverse mapping URL)? But a few hours of googling didn’t help me to find any info about that why we even need them? Will be really thankfull if you could show some practical examples.

well. let me explain. below section is from mux documentation, could someone explain what is this? why we need this? and in which real example we use this?

Now let’s see how to build registered URLs.

Routes can be named. All routes that define a name can have their URLs built, or “reversed”. We define a name calling Name() on a route. For example:

r := mux.NewRouter()
r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler).
To build a URL, get the route and call the URL() method, passing a sequence of key/value pairs for the route variables. For the previous route, we would do:

url, err := r.Get(“article”).URL(“category”, “technology”, “id”, “42”)
…and the result will be a url.URL with the following path:


• Constructing redirects to send to a client - eg programmatically, so you don’t have to fix the URLs in your code elsewhere

• Building examples & tests

• Generating docs