From 53c7f93f83c06e9632c3675a8430f864ad014227 Mon Sep 17 00:00:00 2001 From: Mrinal Wadhwa Date: Thu, 8 Nov 2018 12:09:27 -0800 Subject: [PATCH] docs: tweak examples --- example_test.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/example_test.go b/example_test.go index cec129b..84b1b64 100644 --- a/example_test.go +++ b/example_test.go @@ -2,13 +2,15 @@ package did_test import ( "fmt" + "log" + "github.com/ockam-network/did" ) func ExampleParse() { d, err := did.Parse("did:example:q7ckgxeq1lxmra0r") if err != nil { - fmt.Printf("%#v", err) + log.Fatal(err) } fmt.Printf("%#v", d) // Output: &did.DID{Method:"example", ID:"q7ckgxeq1lxmra0r", IDStrings:[]string{"q7ckgxeq1lxmra0r"}, Path:"", PathSegments:[]string(nil), Fragment:""} @@ -17,7 +19,7 @@ func ExampleParse() { func ExampleParse_withPath() { d, err := did.Parse("did:example:q7ckgxeq1lxmra0r/a/b") if err != nil { - fmt.Printf("%#v", err) + log.Fatal(err) } fmt.Printf("%#v", d) // Output: &did.DID{Method:"example", ID:"q7ckgxeq1lxmra0r", IDStrings:[]string{"q7ckgxeq1lxmra0r"}, Path:"a/b", PathSegments:[]string{"a", "b"}, Fragment:""} @@ -26,7 +28,7 @@ func ExampleParse_withPath() { func ExampleParse_withFragment() { d, err := did.Parse("did:example:q7ckgxeq1lxmra0r#keys-1") if err != nil { - fmt.Printf("%#v", err) + log.Fatal(err) } fmt.Printf("%#v", d) // Output: &did.DID{Method:"example", ID:"q7ckgxeq1lxmra0r", IDStrings:[]string{"q7ckgxeq1lxmra0r"}, Path:"", PathSegments:[]string(nil), Fragment:"keys-1"} @@ -40,13 +42,13 @@ func ExampleDID_String() { func ExampleDID_String_withPath() { d := &did.DID{Method: "example", ID: "q7ckgxeq1lxmra0r", Path: "a/b"} - fmt.Println(d) + fmt.Println(d.String()) // Output: did:example:q7ckgxeq1lxmra0r/a/b } func ExampleDID_String_withPathSegments() { d := &did.DID{Method: "example", ID: "q7ckgxeq1lxmra0r", PathSegments: []string{"a", "b"}} - fmt.Println(d) + fmt.Println(d.String()) // Output: did:example:q7ckgxeq1lxmra0r/a/b }