Build a Scheduled News Reader with Golang, Reddit and SendGrid


May 07, 2014
Written by
SendGrid Team
Contributor
Opinions expressed by Twilio contributors are their own

Build a Scheduled News Reader with Golang, Reddit and SendGrid

GoNewsI have too many good things to say about Go. I absolutely love the language. I could write a full article just on how much I love it and why. Instead, I'll use Go to help you learn more about Go. Very meta.

Luckily, I am not the only person on our Developer Relations team that loves Go. Yamil is a keen Gopher, and has already written a basic Golang wrapper for the SendGrid API. But especially since the engineering team is adopting Go, we need more examples.

As the title states, we will be building a Scheduled News Reader to email us every morning at 6am, with the latest news and headlines from the Golang Sub-Reddit, using SendGrid’s API and Reddit’s API. This is a fun little hack, but also fairly useful, as I myself am keen to keep up to date with what’s happening in the Golang world. How better to find out, than have the headlines delivered to your email inbox every morning to read over breakfast!?

This sample app is quite detailed, so I'll provide an overview of how it works here, and you can find a walkthrough on GitHub.

Prerequisites

For this hack, we’re going to use Reddit’s API, SendGrid’s API, and our Golang library for said API. You can find the relevant libraries you require below: Other than those, we will be sticking to the excellent native libs from Go. Of course, you'll also need a SendGrid account.

Once you’ve done that, use Go Get to install the dependencies above. I.E.

go get github.com/sendgrid/sendgrid-go

The Rest of the Code

With your prerequisites taken care of, the full walk-through will show you how to:
  • Get the latest headlines from the Go sub-reddit
  • Turn the blob of JSON into something human-readable
  • Refactor the code to work for any sub-reddit
  • Use the score to decide which stories to show
  • Turn the stories into a daily email
If you're down with Go, but not ready to check out this example app, learn why SendGrid chose Golang (and how to convince your company to do the same).

Recommended For You



Most Popular


Send With Confidence

Partner with the email service trusted by developers and marketers for time-savings, scalability, and delivery expertise.