go-notificationgo-notification
Getting Started

Installation

Add go-notification to your Go project.

Requirements

  • Go 1.22 or newer
  • For the database channel: PostgreSQL, MySQL, or SQLite — connected via database/sql.

Install

terminal.sh
go get github.com/gopackx/go-notification

That's the entire dependency — the core has no external SDKs. Drivers for specific providers live under subpackages and are pulled in only when you import them.

Import what you need

The root module path is github.com/gopackx/go-notification, and its package name is notification. You import the root package for the engine, then add only the driver subpackages you actually use — nothing is enabled by default, and there is no wildcard import.

main.go
import (
    notification "github.com/gopackx/go-notification"
    "github.com/gopackx/go-notification/channel/mail"
    "github.com/gopackx/go-notification/channel/mail/mailgun"
    "github.com/gopackx/go-notification/channel/whatsapp/waha"
)

This keeps the binary small. If you never use Slack, the Slack driver isn't compiled in.

The named import (notification "github.com/...") is conventional because the path ends in go-notification but the package is named notification. The alias makes that explicit.

Verify

main.go
package main

import (
    "fmt"

    notification "github.com/gopackx/go-notification"
)

func main() {
    notifier := notification.New(notification.Config{})
    defer notifier.Close()
    fmt.Println("go-notification ready:", notifier != nil)
}

Run go run . — if it prints go-notification ready: true, you're done.

Running the examples

The repository ships runnable programs under _examples/. They form a separate Go module (github.com/gopackx/go-notification/_examples) so that the library itself keeps zero third-party dependencies: the examples that use the database channel pull in the cgo-free modernc.org/sqlite driver, which the library doesn't need. Run them from that directory, not from the repository root:

terminal.sh
git clone https://github.com/gopackx/go-notification
cd go-notification/_examples
go run ./basic

Swap ./basic for ./multi-channel, ./whatsapp-waha, ./email-api or ./full-example. Each program documents the environment variables it reads at the top of its main.go; the walkthroughs are under Examples.

Next step

Continue with Quick Start to send your first notification.