forked from coracle/nostrlib
compile-time check for json.Marshaler and json.Unmarshaler.
This commit is contained in:
@@ -2,6 +2,7 @@ package nostr
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
stdjson "encoding/json"
|
||||
"fmt"
|
||||
"unsafe"
|
||||
)
|
||||
@@ -17,6 +18,11 @@ var ZeroID = ID{}
|
||||
// ID represents an event id
|
||||
type ID [32]byte
|
||||
|
||||
var (
|
||||
_ stdjson.Marshaler = ID{}
|
||||
_ stdjson.Unmarshaler = (*ID)(nil)
|
||||
)
|
||||
|
||||
func (id ID) String() string { return "id::" + id.Hex() }
|
||||
func (id ID) Hex() string { return hex.EncodeToString(id[:]) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user