Skip to content

Commit

Permalink
chore: handling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanCapistrano committed Sep 17, 2023
1 parent d4607e6 commit a2c6150
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -11,17 +13,24 @@ 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)

// Submitting some message.
// 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)
}
}

0 comments on commit a2c6150

Please sign in to comment.