Standard library / net/url

url.Values.Set()

Replace all values for a key with one value. Expected stdout: '[2]\n'.

Formal Syntax & Structure

go syntaxgo
func (v Values) Set(key, value string)

Parameters & Attributes

NameTypeDescription
keystringHeader or query parameter name.
valuestringValue to store.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/url")
func main() { v := url.Values{"a": {"1"}}; v.Set("a", "2"); fmt.Println(v["a"]) }
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