Standard library / net/url

url.Values.Encode()

Encode query pairs sorted by key, preserving order of each value list. Expected stdout: 'a=1&b=a+b\n'.

Formal Syntax & Structure

go syntaxgo
func (v Values) Encode() string

Return Value

string

Operation result; check errors and validity indicators when returned.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/url")
func main() { v := url.Values{"a": {"1"}}; v.Add("b", "a b"); fmt.Println(v.Encode()) }
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)  }}
Go Reference