Query and fragment parameters
Get, set, or delete standard query parameters and query-like parameters inside URL fragments.
URL helpers for Go
A Go library for inspecting, validating, and modifying URL components.
go get github.com/chengchuu/gurl
Use Go 1.19 or later. The public package lives at the module root, so the install and import paths are identical.
go get github.com/chengchuu/gurlimport "github.com/chengchuu/gurl"Pass a URL and key to GetQueryParam. The helper parses the URL with Go's standard library and returns the first value for that key.
value, err := gurl.GetQueryParam(
"https://example.com/search?q=go&lang=en",
"q",
)
if err != nil {
log.Fatal(err)
}
fmt.Println(value) // goEach operation works on URL strings in memory; the package does not send network requests.
Get, set, or delete standard query parameters and query-like parameters inside URL fragments.
Read or replace paths, hosts, hostnames, and protocols while preserving other parsed components.
Check schemes and hosts, read path file extensions, or remove a URL's query and fragment.
The full reference is generated from exported Go declarations and GoDoc comments.
Requires Go 1.19 or later and is available under the MIT License. Read the package on pkg.go.dev.