Registry /
messaging / libp2p-go-libp2p-pubsub
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
pubsub
✓ github.com/libp2p/go-libp2p-pubsub
Subscribe to a topic using GossipSub.
package main
import (
"context"
"fmt"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p"
)
func main() {
ctx := context.Background()
host, _ := libp2p.New(libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
ps, _ := pubsub.NewGossipSub(ctx, host)
sub, _ := ps.Subscribe("test-topic")
msg, _ := sub.Next(ctx)
fmt.Println(string(msg.Data))
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
0.16.0latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.