Standard library / net/textproto

textproto.MIMEHeader.Add()

Append a value under the canonicalized key; retain previous values. Expected stdout: '[a b]\n'.

Formal Syntax & Structure

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

Parameters & Attributes

NameTypeDescription
keystringMIME header field name.
valuestringText value to write or associate.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/textproto")
func main() {  h := textproto.MIMEHeader{}  h.Add("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