Standard library / net/url
url.ParseQuery()
Parse a query into lists of values and return an error for malformed pairs. Expected stdout: '[1 2] true\n'.
Formal Syntax & Structure
go syntaxgo
func ParseQuery(query string) (Values, error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| query | string | Encoded query string without the leading question mark. |
Return Value
(Values, error)
Operation result; check errors and validity indicators when returned.
Working Example
Example Snippetgo
package main
import ( "fmt" "net/url")
func main() { v, e := url.ParseQuery("a=1&bad=%ZZ&a=2"); fmt.Println(v["a"], e != nil) }
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}