From a2c61500a08da749c930070ede1e6192dfc932dd Mon Sep 17 00:00:00 2001 From: AllanCapistrano Date: Sun, 17 Sep 2023 15:03:35 -0300 Subject: [PATCH] chore: handling errors --- main.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 93c28b8..20d2318 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,8 @@ package main import ( "fmt" + "log" + "strings" infoNode "github.com/allancapistrano/tangle-client-go/info" "github.com/allancapistrano/tangle-client-go/messages" @@ -11,7 +13,10 @@ func main() { nodeURL := "http://127.0.0.1:14265" // Network info - nodeInfo := infoNode.GetNodeInfo(nodeURL) + nodeInfo, err := infoNode.GetNodeInfo(nodeURL) + if err != nil { + log.Fatal(err) + } fmt.Println(nodeInfo) @@ -19,9 +24,13 @@ func main() { // messages.SubmitMessage(nodeURL, "LB_REPLY", "{asdfghjkl}", 15) // TODO: Conseguir ler esse tipo de mensagem // Reading some messages by an index. - messages := messages.GetAllMessagesByIndex(nodeURL, "LB_REPLY") + messages, err := messages.GetAllMessagesByIndex(nodeURL, "LB_ENTRY_REPLY") + if err != nil { + log.Fatal(err) + } for _, v := range messages { + fmt.Println([]byte(strings.Trim(v.Content, "\t"))) fmt.Printf("Index: %s | Content: %s\n", v.Index, v.Content) } }