Standard library / encoding/pem

encoding/pem.Block

PEM container containing a type label, optional headers and decoded payload bytes. The label is not proof of payload validity or authenticity. Expected stdout: 'DEMO sample Go\n'.

Formal Syntax & Structure

go syntaxgo
type Block struct {  Type    string  Headers map[string]string  Bytes   []byte}

Working Example

Example Snippetgo
package main
import (  "encoding/pem"  "fmt")
func must(e error) {  if e != nil {    panic(e)  }}
func main() {  b := pem.Block{Type: "DEMO", Headers: map[string]string{"Note": "sample"}, Bytes: []byte("Go")}  got, _ := pem.Decode(pem.EncodeToMemory(&b))  fmt.Println(got.Type, got.Headers["Note"], string(got.Bytes))}
Go Reference