Add `Create` example to godoc

License: MIT
Signed-off-by: default avatarRob Brackett <rob@robbrackett.com>
parent 6e1876c2
......@@ -41,3 +41,17 @@ func TestEmbedPublicKey(t *testing.T) {
t.Fatalf("pid mismatch: %s != %s", pid, embeddedPid)
}
}
func ExampleCreate() {
// Generate a private key to sign the IPNS record with. Most of the time,
// however, you'll want to retrieve an already-existing key from IPFS using
// go-ipfs/core/coreapi CoreAPI.KeyAPI() interface.
privateKey, publicKey, err := ic.GenerateKeyPair(ic.RSA, 2048)
// Create an IPNS record that expires in one hour and points to the IPFS address
// /ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5
ipnsRecord, err := Create(privateKey, []byte("/ipfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5"), 0, time.Now().Add(1*time.Hour))
if err != nil {
panic(err)
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment