Reputation: 26483
I have following url:
targetUrl := "http://google.com/foo/bar?a=1&b=2"
myUrl, err := url.Parse(targetUrl)
I wonder how I can obtain last path segment (bar
) from myUrl.Path
?
Upvotes: 8
Views: 9725
Reputation: 121019
Use path.Base to get the last element of a path: path.Base(myUrl.Path)
Upvotes: 13