Help us shape the future of Go! Take the 2026 Go Developer Survey

slackit

package module
v0.0.0-...-d95d92b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 3 Imported by: 0

README

slackit

GoDoc

About

Slackit is a very simple library for posting messages to slack. I use this code all over my projects so even though it's simple I thought it would be useful to put it into a library.

Example

url := os.Getenv("SLACK_URL")
payload := &slackit.Payload{Text: "Hello from slackit!"}

err := slackit.PostMessage(url, payload)
if err != nil {
    log.Printf("Error posting to slack: %s\n", err)
}

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func PostMessage

func PostMessage(url string, p *Payload) error

PostMessage posts the payload to slack

Example
package main

import (
	"log"
	"os"

	"github.com/sfreiberg/slackit"
)

func main() {
	url := os.Getenv("SLACK_URL")
	payload := &slackit.Payload{Text: "Hello from slackit!"}

	err := slackit.PostMessage(url, payload)
	if err != nil {
		log.Printf("Error posting to slack: %s\n", err)
	}
}

Types

type Payload

type Payload struct {
	Text      string `json:"text"`
	IconURL   string `json:"icon_url,omitempty"`
	IconEmoji string `json:"icon_emoji,omitempty"`
	Username  string `json:"username,omitempty"`
}

Payload holds the information that will be sent to slack

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL