package main import ( "fmt" "net/textproto" ) func main() { header := textproto.MIMEHeader{} header.Set("Content-Type", "text/plain; charset=utf-8") fmt.Println(header) }
package main import ( "fmt" "net/textproto" ) func main() { header := textproto.MIMEHeader{ "Content-Type": {"text/html; charset=utf-8"}, "X-Custom-Header": {"value1", "value2"}, } header.Set("Content-Type", "application/json") fmt.Println(header.Get("X-Custom-Header")) }This code shows how to set a header value in an existing MIME header. It creates a MIME header with two header fields, "Content-Type" and "X-Custom-Header", and then sets the value of "Content-Type" to "application/json". Finally, it prints the value of the "X-Custom-Header" field.