Theory and Practice
About Archives Categories Tags Authors 中文 ไทย

[Golang] Remove Query String From URL

March 26, 2016
Edit on Github

Remove query string from URL in Golang.

import "net/url"

func StripQueryString(inputUrl string) string {
      u, err := url.Parse(inputUrl)
      if err != nil {
              panic(err)
      }
      u.RawQuery = ""
      return u.String()
}

Tested on: Ubuntu Linux 15.10, Go 1.6.


References:

[1]go url remove query
[2]url - The Go Programming Language

Author: Siong-Ui Te
∈ Category: Go
∑ Tags: Go , Golang , String Manipulation , Go net/url
Powered by Github Pages, Pelican, pyScss.