From 7b0af23f1af2746dbdf3c442e30754ba7d16bd84 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Tue, 11 Apr 2023 07:36:59 -0300 Subject: [PATCH] implement Stringer for Event. --- event.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/event.go b/event.go index b093934..844925b 100644 --- a/event.go +++ b/event.go @@ -3,6 +3,7 @@ package nostr import ( "crypto/sha256" "encoding/hex" + "encoding/json" "fmt" "time" @@ -41,6 +42,15 @@ const ( KindZap int = 9735 ) +// Event Stringer interface, just returns the raw JSON as a string +func (evt *Event) String() string { + if evt == nil { + return "null" + } + j, _ := json.Marshal(evt) + return string(j) +} + // GetID serializes and returns the event ID as a string func (evt *Event) GetID() string { h := sha256.Sum256(evt.Serialize())