compile-time check for json.Marshaler and json.Unmarshaler.
This commit is contained in:
@@ -3,6 +3,7 @@ package nostr
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
stdjson "encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
@@ -65,6 +66,11 @@ var ZeroPK = PubKey{}
|
||||
|
||||
type PubKey [32]byte
|
||||
|
||||
var (
|
||||
_ stdjson.Marshaler = PubKey{}
|
||||
_ stdjson.Unmarshaler = (*PubKey)(nil)
|
||||
)
|
||||
|
||||
func (pk PubKey) String() string { return "pk::" + pk.Hex() }
|
||||
func (pk PubKey) Hex() string { return hex.EncodeToString(pk[:]) }
|
||||
func (pk PubKey) MarshalJSON() ([]byte, error) {
|
||||
|
||||
Reference in New Issue
Block a user