This is an unofficial client library for interacting with the Plunk API using Go.
Make sure your project is using Go Modules (it will have a go.mod file in its root if it already is):
go mod initThen, reference plunk-go in a Go program with import:
import (
"github.com/NdoleStudio/plunk-go"
)Run any of the normal go commands (build/install). The Go toolchain will resolve and fetch the plunk-go module automatically. Alternatively, you can also explicitly go get the package into a project:
go get github.com/NdoleStudio/plunk-go- Contacts
-
POST /contacts: Create a new contact or update existing (upsert by email) -
DELETE /contacts/{id}: Permanently delete a contact -
GET /contacts: Get a paginated list of contacts with cursor-based pagination
-
- Track
-
POST /track: Track an event for a contact
-
An instance of the client can be created using plunk.New().
package main
import (
"github.com/NdoleStudio/plunk-go"
)
func main() {
plunkClient := plunk.New(plunk.WithSecretKey(/* Secret Key from https://next-app.useplunk.com/settings?tab=general*/))
}All API calls return an error as the last return object. All successful calls will return a nil error.
request := &plunk.CreateContactRequest{
Email: "user@example.com"
Subscribed: true
Data: map[string]any{
"firstName": "John",
"lastName": "Doe",
"plan": "premium",
}
}
contact, response, err := plunkClient.Contacts.Create(context.Background(), request)
if err != nil {
//handle error
}You can run the unit tests for this client from the root directory using the command below:
go test -vThis project is licensed under the MIT License - see the LICENSE file for details

