带preg_match的Go路由器

I'm trying to rewrite a router on Go that will call for specific functions if request_uri matches the pattern. It should accept following routes:

|^/v2/Command/create$|
|^/([^/]+)/postCommands$|
|^/v2/user/sessions/(.+)/.+|

There are some others and it should be scalable, so the new route can be simply added to a map Right now it is done on PHP via preg_match($pattern, $_SERVER['REQUEST_URI'], $params) Is there a method to do a smiliar thing on Go?

https://github.com/gorilla/mux should help you much at this.

r := mux.NewRouter()
r.HandleFunc("/products/{key}", ProductHandler)
r.HandleFunc("/articles/{category}/", ArticlesCategoryHandler)
r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler)

vars := mux.Vars(request)
category := vars["category"]