package main import ( "encoding/json" "github.com/go-redis/redis/v7" "os/exec" "time" ) type Message struct { ID string Name string Email string } func main() { client := redis.NewClient(&redis.Options{ Addr: "10.1.3.100:6379", Password: "", DB: 0, }) println("waiting for messages...") channel := client.Subscribe("qq") _, err := channel.Receive() if err != nil { panic(err) } for msg := range channel.Channel() { if msg.Channel != "qq" { return } bytes := []byte(msg.Payload) var data Message json.Unmarshal(bytes, &data) exec.Command("./makejpg.sh", data.ID, data.Name, data.Email) println("Printing", data.ID, data.Name, data.Email, "at", time.Now().String()) } }