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
?
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
?
Use path.Base to get the last element of a path: path.Base(myUrl.Path)
© 2022 - 2024 — McMap. All rights reserved.