Standard library / net/http

http.Header.Values()

Return the values for a canonical header key; returned slice aliases stored values. Expected stdout: '[a]\n'.

Formal Syntax & Structure

go syntaxgo
func (h Header) Values(key string) []string

Parameters & Attributes

NameTypeDescription
keystringHeader or query parameter name.

Return Value

[]string

Operation result; check errors and validity indicators when returned.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/http")
func main() { h := http.Header{}; h.Set("X-Demo", "a"); fmt.Println(h.Values("x-demo")) }
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