Standard library / net/http

http.Header.Add()

Append another value under the canonical header key. Expected stdout: '[a b]\n'.

Formal Syntax & Structure

go syntaxgo
func (h Header) Add(key, value string)

Parameters & Attributes

NameTypeDescription
keystringHeader or query parameter name.
valuestringValue to store.

Working Example

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