Skip to content

Commit

Permalink
docs: tweak examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mrinalwadhwa committed Nov 8, 2018
1 parent 262bb2e commit 53c7f93
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:""}
Expand All @@ -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:""}
Expand All @@ -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"}
Expand All @@ -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
}

Expand Down

0 comments on commit 53c7f93

Please sign in to comment.