import "github.com/pebbe/zmq4" func main() { push, _ := zmq4.NewSocket(zmq4.PUSH) push.Bind("tcp://*:5557") pull, _ := zmq4.NewSocket(zmq4.PULL) pull.Connect("tcp://localhost:5557") push.Send("Hello, World!", 0) msg, _ := pull.Recv(0) fmt.Println("Received message:", msg) }
import "github.com/pebbe/zmq4" func main() { pub, _ := zmq4.NewSocket(zmq4.PUB) pub.Bind("tcp://*:5556") sub, _ := zmq4.NewSocket(zmq4.SUB) sub.Connect("tcp://localhost:5556") sub.SetSubscribe("") pub.Send("Test message", 0) msg, _ := sub.Recv(0) fmt.Println("Received message:", msg) }In this example, we create a PUB socket and bind it to a TCP port. We then create a SUB socket and connect it to the same TCP port. We subscribe to all messages by calling `sub.SetSubscribe("")`. We send a message from the PUB socket and receive it on the SUB socket. Based on the examples above, the package library is a Go implementation of the ZeroMQ messaging library.