I want to get all new events from docker via the golang integration. The problem is that it returns two channels and I couldn't figure out how to subscribe to them.
cli, err := client.NewClientWithOpts(client.WithVersion("1.37"))
if err != nil {
panic(err)
}
ctx, _ := context.WithCancel(context.Background())
msg, err := <- cli.Events(ctx, types.EventsOptions{})
There are many solutions. A solution could be:
msgs, errs := cli.Events(ctx, types.EventsOptions{})
for {
select {
case err := <-errs:print(err)
case msg := <-msgs:print(msg)
}
}