Goroutines as job queues
Perhaps you don't need a job queue for your particular task. Using a goroutine for a task is often sufficient. Let's say that we want to send an email asynchronously during some particular task. We can send this email using a goroutine within our function.
For this example, I'm going to send an email via Gmail. To do so, you may need to allow less secure app access for email authentication to work (https://myaccount.google.com/lesssecureapps?pli=1). This is not recommended to do in the long term; it's just a simple way to show a real-world email interaction. If you're interested in building a more robust email solution, you can use the Gmail API at https://developers.google.com/gmail/api/quickstart/go. Let's get ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access