Fix issue with fake deadlock

This commit is contained in:
2024-06-17 21:11:19 +02:00
parent 6f2b472c83
commit eb43976857

10
main.go
View File

@@ -46,7 +46,9 @@ func main() {
listener.initialize() listener.initialize()
status := make(chan error) status := make(chan error)
for event := range listener.Create { for {
select {
case event := <-listener.Create:
log.Printf("Create event: %+v\n", event) log.Printf("Create event: %+v\n", event)
eventCopy := event eventCopy := event
go func() { go func() {
@@ -56,7 +58,9 @@ func main() {
log.Printf("Status: %s\n", status) log.Printf("Status: %s\n", status)
} }
}() }()
case <-time.After(1 * time.Minute):
// Perform some action or simply continue to avoid deadlock
log.Println("Consumer is alive, but has no new events.")
}
} }
time.Sleep(1 * time.Hour)
} }