Standard library / net/url

url.Values.Has()

Report whether a key is present, even when its value is empty. Expected stdout: 'true false\n'.

Formal Syntax & Structure

go syntaxgo
func (v Values) Has(key string) bool

Parameters & Attributes

NameTypeDescription
keystringHeader or query parameter name.

Return Value

bool

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.Set("empty", "")  fmt.Println(v.Has("empty"), v.Has("missing"))}
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