Get basename of url by Golang

Apr. 4, 2018

targetURL := "http://www.example.com/one/two/three.json?output=four"
u, err := url.Parse(targetURL)
if err != nil {
  panic(err)
}
fmt.Println(path.Base(u.Path))
// three.json