Standard library / net/textproto
textproto.MIMEHeader.Set()
Replace all existing values for the key with a single value. Expected stdout: '[c]\n'.
Formal Syntax & Structure
go syntaxgo
func (h MIMEHeader) Set(key, value string)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | string | MIME header field name. |
| value | string | Text 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") h.Set("x-demo", "c") 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) }}