Standard library / net/textproto
textproto.MIMEHeader.Get()
Return the first value for a canonicalized key, or empty if missing. Use Values to inspect repeats. Expected stdout: 'a\n'.
Formal Syntax & Structure
go syntaxgo
func (h MIMEHeader) Get(key string) stringParameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | string | MIME header field name. |
Return Value
string
First value, or empty string.
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.Get("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) }}