go - net/url package: strip query from url -


i wanted make sure wasn't missing on net/url package. there way url without query, without using using strings package strip out?

package main  import (     "fmt"     "net/url" )  func main() {     u, _ := url.parse("/url?foo=bar&foo=baz")     fmt.printf("full uri: %#v\n", u.string())     fmt.printf("query: %#v", u.query()) } 

http://play.golang.org/p/injlx_elap

i not sure if asking can use u.path attribute path of url or of attributes specified url

type url struct {     scheme   string     opaque   string    // encoded opaque data     user     *userinfo // username , password information     host     string    // host or host:port     path     string     rawquery string // encoded query values, without '?'     fragment string // fragment references, without '#' } // scheme://[userinfo@]host/path[?query][#fragment] 

example:

 package main  import (     "fmt"     "net/url" )  func main() {     u, _ := url.parse("http://www.test.com/url?foo=bar&foo=baz#this_is_fragment")     fmt.println("full uri:", u.string())     fmt.println("scheme:", u.scheme)     fmt.println("opaque:", u.opaque)     fmt.println("host:", u.host)     fmt.println("path", u.path)     fmt.println("fragment", u.fragment)     fmt.println("rawquery", u.rawquery)     fmt.printf("query: %#v", u.query()) } 

http://play.golang.org/p/mije73rugw


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -