Skip to content
SDKs
Go

Go SDK

The Plunk Go SDK is a wrapper around the Plunk API that allows you to easily, and type-safely, interact with the Plunk API from your Go applications.

Source code for the SDK can be found on GitHub (opens in a new tab).

⚠️

This SDK is endorsed by Plunk, but not made by Plunk. If you have any issues with the SDK, please open an issue on the GitHub repository.

Installing

Install the SDK using go get:

go get github.com/kayode0x/plunk

Getting Started

Interactions with the Plunk API are made through a client, create one using your secret key.

p, _ := plunk.New("YOUR_API_KEY")

Sending events

Use the TriggerEvent method to send events to Plunk.

Parameters

  • Event: The name of the event to publish
  • Email: The email address of the user to publish the event to
p, err := New(secretKey, opts)
 
payload := &EventPayload{
    Event: "new-project",
    Email: "hello@useplunkc.com",
}
 
resp, err := p.TriggerEvent(payload)

Sending emails

Use the sendTransactionalEmail method to send transactional emails.

Parameters
  • To: The email address of the recipient
  • Subject: The subject of the email
  • Body: The body of the email (HTML, plain text, or Markdown)
p, err := plunk.New("YOUR_API_KEY", config)
 
payload := &TransactionalEmailPayload{
    To:      "hello@useplunk.com",
    Subject: "Welcome to Plunk",
    Body:    "<h1>Hello world!</h1>",
}
 
response, err := plunk.SendTransactionalEmail(payload)
Last updated on April 21, 2023