There is one thing I do not understand. In you `connect()` function you call `defer cancel()` to close the connection when you exit the function `connect()`. But then, how can you actually use that connection in the other parts of the app?

A man with passion for code and for some strange things that sometimes happen in IT organizations. Views and thoughts here are my own.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store