aboutsummaryrefslogtreecommitdiff
path: root/src/encoding
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding')
-rw-r--r--src/encoding/pem/example_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/encoding/pem/example_test.go b/src/encoding/pem/example_test.go
index 900b31c8ba..806e7bbbf7 100644
--- a/src/encoding/pem/example_test.go
+++ b/src/encoding/pem/example_test.go
@@ -9,6 +9,7 @@ import (
"encoding/pem"
"fmt"
"log"
+ "os"
)
func ExampleDecode() {
@@ -42,3 +43,23 @@ and some more`)
fmt.Printf("Got a %T, with remaining data: %q", pub, rest)
// Output: Got a *rsa.PublicKey, with remaining data: "and some more"
}
+
+func ExampleEncode() {
+ 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)
+ }
+ // Output:
+ // -----BEGIN MESSAGE-----
+ // Animal: Gopher
+ //
+ // dGVzdA==
+ // -----END MESSAGE-----
+}