Errors in goroutines

Fix goroutine errors in Go by using the race detector and ensuring proper synchronization and exit paths.

Goroutine errors in Go are typically caused by data races, deadlocks, or improper channel usage. Use the -race flag to detect data races and ensure all goroutines exit cleanly to prevent deadlocks.

go run -race main.go

If you encounter a deadlock, verify that every goroutine has a path to exit and that channels are buffered or properly closed.