SparkPost Client Library for Go Released!

Dave Gray
Jan. 22, 2016 by Dave Gray

Go SparkPost Library Released

Our Go client library is now publicly available!

We’ve been using it internally for various projects during development and now it’s time to go public. If you’re not familiar, “Go from Google” AKA Golang is a newer programming language, as these things, ahem, go. It’s been used to build a variety of publicly-available software including Docker and the Let’s Encrypt certificate authority. For a browser-based introduction to Go, check out A Tour of Go.

Go is statically typed and compiled, unlike most of the other languages that we have client libraries for. This makes the code a bit more verbose, and can make parsing JSON a bit frustrating at first. One of the goals of this library is to minimize that frustration during the “getting started with SparkPost and Go” phase.

So how do you use the SparkPost client library for Go? Once your Go workspace is set up, you can run:

This will download the client library code so it’s ready to import:

Now we’ll initialize the library with connection and authentication settings, pulling our API key from the environment:

With the setup and config out of the way, what can you do today with our Go client library?

We have full support for the Transmissions, Templates, and Recipient Lists endpoints, which is enough to support most sending use cases. Templates and Recipient Lists can be pre-created, which speeds things up if you’ll be reusing the same ones a lot – they can be specified by ID. If you won’t be reusing, or if you’d simply prefer to be more dynamic, Transmissions can also be sent using an inline Template and/or Recipient List, meaning that they’re included as part of the Transmissions call.

Here’s an example of what sending a transmission looks like:

Using the snippets above, you’re ready to start sending through SparkPost with Go. If you’ve been paying close attention, you’ve noticed that combining these code snippets with your API key gives you a way to send test messages. You could even build a CLI that allows you to send tests specifying the sender, recipient, and other fields as flags.

So what’s next for the Go client library?

Watch this space for more code examples and more advanced usage. We plan to use this library in several of our upcoming projects, including a sample application demonstrating how to easily parse event data out-of-band. We’re also working on support for Message Events, which lets you search through the last couple day’s worth of event data generated in your account.

What else will you build with our client libraries? We’re curious to see, so drop us a line and let us know.


Dev Survival Guide Blog Footer

Share your Thoughts

Your email address will not be published.

Related Content

Community Spotlight: How Topol Makes Creating Beautiful HTML Email Templates Easy

Building HTML email templates is hard. Learn about the app that Jan Tlapak and Sendmark created for anybody in need of building beautiful HTML emails.

read more

Running Your First Technical Workshop: The "I Have No Idea What I'm Doing" Edition

Running a technical workshop is difficult! Where do you start? How much time do you allot? What audience do you aim for? Cole talks through what he learned.

read more

Introducing Our SendGrid Template Migration Tool

Automatically migrate any SendGrid template over to SparkPost. This open source tool supports both UI- and API-driven email template migration workflows.

read more

Start sending email in minutes!

The world’s most powerful email delivery solution is now yours in a developer-friendly, quick to set up cloud service. Open a SparkPost account today and send up to 100,000 emails per month for free.

Send 100K Emails/Month For Free

Send this to a friend