Fix example compilation error (#50)

This commit is contained in:
Kevin Lee
2023-02-03 22:36:21 +08:00
committed by GitHub
parent cc6ec2b886
commit 15370a9acd
3 changed files with 28 additions and 11 deletions

View File

@@ -7,18 +7,35 @@ A set of useful things for [Nostr Protocol](https://github.com/nostr-protocol/no
<a href="https://godoc.org/github.com/nbd-wtf/go-nostr"><img src="https://img.shields.io/badge/api-reference-blue.svg?style=flat-square" alt="GoDoc"></a>
Install go-nostr:
```bash
go get github.com/nbd-wtf/go-nostr
```
### Generating a key
``` go
sk, _ := nostr.GenerateKey()
pk, _ := nostr.GetPublicKey(sk)
nsec, _ := nip19.EncodePrivateKey(sk)
npub, _ := nip19.EncodePublicKey(pk)
package main
fmt.Println("sk:", sk)
fmt.Println("pk:", nostr.GetPublicKey(sk))
fmt.Println(nsec)
fmt.Println(npub)
import (
"fmt"
"github.com/nbd-wtf/go-nostr"
"github.com/nbd-wtf/go-nostr/nip19"
)
func main() {
sk := nostr.GeneratePrivateKey()
pk, _ := nostr.GetPublicKey(sk)
nsec, _ := nip19.EncodePrivateKey(sk)
npub, _ := nip19.EncodePublicKey(pk)
fmt.Println("sk:", sk)
fmt.Println("pk:", pk)
fmt.Println(nsec)
fmt.Println(npub)
}
```
### Subscribing to a single relay