Go-ipfs pubsub get the peer-id from the message

Hi everyone

I am trying to use the experimental feature pubsub to get messages from other nodes.
I created a GO application using the library shell “github.com/ipfs/go-ipfs-api”

so I can get messages successful with the following structure

spew.Dump(msg):
(shell.Message)(0xc00009af00)({
**From: (peer.ID) (len=34) <peer.ID Qm
KsYn3Y>,**
Data:
Seqno:
TopicIDs:
})

I would like to get the peerId, but I get <peer.ID Qm*KsYn3Y>
someone could be so kind to tell me how to get this value

Thanks in advance

Wouldn’t msg.From or msg.From.Pretty() give you the peer id?

1 Like

Thanks a lot…

I had also found the following function to get the peer id (encoded b58)

/**

  • Pretty
  • returns a b58-encoded string of the ID
  • @param string ID
  • @return b58-encoded string ID
    */
    func (id ID) Pretty() string {
    return IDB58Encode(id)
    }

I am a beginner in IPFS and Go world, because of that the most library are new for me…

again thanks for you help
Diana

1 Like