Encode writes the PEM encoding of b to out.
package main import ( "encoding/pem" "log" "os" ) func main() { block := &pem.Block{ Type: "MESSAGE", Headers: map[string]string{ "Animal": "Gopher", }, Bytes: []byte("test"), } if err := pem.Encode(os.Stdout, block); err != nil { log.Fatal(err) } }