u, err := url.Parse("http://example.com/path?query=value") if err != nil { panic(err) } fmt.Println(u.Scheme, u.Host, u.Path, u.RawQuery)
u := &url.URL{ Scheme: "http", Host: "example.com", Path: "/path", RawQuery: "query=value", } fmt.Println(u.String())
base, err := url.Parse("http://example.com") if err != nil { panic(err) } u, err := base.Parse("/path?query=value") if err != nil { panic(err) } fmt.Println(u.String())This will output: `http://example.com/path?query=value` Overall, net/url package is used for parsing, constructing and manipulating URLs in Go programming language.