Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.
/ go-slack-webhook Public archive

Minimum implementation for posting payload to Slack WebHook URL.

License

Notifications You must be signed in to change notification settings

kenju/go-slack-webhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

go-slack-webhook

Minimum implementation for posting payload to Slack WebHook URL.

Design Background

There are a bunch of other great Slack library in Golang. Please use them at most cases.

However, sometimes you want to reduce the build size of binary as small as possible, and everything you need is a minimum implementation for posting to the Slack Webhook URL.

NOTE

Slack Attachments struct is currently borrowed from https://github.com/nlopes/slack.

Install

go get -u github.com/kenju/go-slack-webhook

Usage

import "github.com/kenju/go-slack-webhook"

func main() {
  pl := &slackwebhook.SlackPayload{
    Channel: os.Getenv("SLACK_CHANNEL"),
    Attachments: []slackwebhook.Attachment{
      {
        Color: "danger",
        Title: "this is a title"
        Text:  "this is a text",
        Fields: []slackwebhook.AttachmentField{
          {"foo", "bar", true},
        },
      },
    },
  }
  resp, err := slackwebhook.SendSlack(pl, os.Getenv("SLACK_WEBHOOK_URL"),)
  if err != nil {
    log.Fatal(err)
  }
  log.Println(resp)
}

About

Minimum implementation for posting payload to Slack WebHook URL.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages