Files
zeekay 66d1c4d404 Update to v4 module path
- Updated module path to github.com/luxfi/czmq/v4
- All imports and dependencies updated for v4 compatibility
- Tests passing with ZeroMQ libraries from Homebrew
2025-08-12 12:10:26 -05:00

38 lines
638 B
Go

//
// Weather update server
// Binds PUB socket to tcp://127.0.0.1:5556
// Publishes random weather updates
//
package main
import (
"fmt"
"math/rand"
czmq "github.com/luxfi/czmq/v4"
)
func main() {
pubEndpoint := "tcp://127.0.0.1:5556"
pubSock, err := czmq.NewPub(pubEndpoint)
if err != nil {
panic(err)
}
defer pubSock.Destroy()
pubSock.Bind(pubEndpoint)
for {
zipcode := rand.Intn(100000)
temperature := rand.Intn(215) - 85
relHumidity := rand.Intn(50) + 10
msg := fmt.Sprintf("%d %d %d", zipcode, temperature, relHumidity)
err := pubSock.SendFrame([]byte(msg), 0)
if err != nil {
panic(err)
}
}
}