Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/easonlin404/go-slack
A simple, flexible Golang wrapper around the Slack webhook API.
https://github.com/easonlin404/go-slack
go golang slack slack-webhook
Last synced: 22 days ago
JSON representation
A simple, flexible Golang wrapper around the Slack webhook API.
- Host: GitHub
- URL: https://github.com/easonlin404/go-slack
- Owner: easonlin404
- License: mit
- Created: 2017-06-03T07:58:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-10T16:36:47.000Z (over 4 years ago)
- Last Synced: 2024-10-02T09:20:21.977Z (about 1 month ago)
- Topics: go, golang, slack, slack-webhook
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# go-slack
A simple, flexible Golang wrapper around the [Slack webhook API](https://api.slack.com). Makes it easy to send notifications to Slack from your application(inspired by nodejs [slack-notify](https://github.com/andrewchilds/slack-notify)).
[![Travis branch](https://img.shields.io/travis/easonlin404/go-slack/master.svg)](https://travis-ci.org/easonlin404/go-slack)
[![Codecov branch](https://img.shields.io/codecov/c/github/easonlin404/go-slack/master.svg)](https://codecov.io/gh/easonlin404/go-slack)
[![Go Report Card](https://goreportcard.com/badge/github.com/easonlin404/gin-slack)](https://goreportcard.com/report/github.com/easonlin404/gin-slack)
[![GoDoc](https://godoc.org/github.com/easonlin404/gin-slack?status.svg)](https://godoc.org/github.com/easonlin404/gin-slack)
## Features
* Send plain text and message with attachments
* Send attachments with markdown syntax
* Debug
* Timeout
* Logger
* [Context](https://golang.org/pkg/context/)(todo)## Installation
```sh
$ go get -u github.com/easonlin404/go-slack
```## Useage
Basic send text message
```go
// You need get your slack WebhookURL from https://api.slack.com/incoming-webhooks
webhookURL := "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
message := Message{
Text: "message",
}r, e := slack.New().
WebhookURL(webhookURL).
SendMessage(message)
```
Send message with attachments
```go
// You need get your slack WebhookURL from https://api.slack.com/incoming-webhooks
webhookURL := "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
message := Message{
Attachments: []Attachment{
{Title: "title",
Fields: []Field{
{Title: "T1", Value: 0, Short: true},
{Title: "T2", Value: 0, Short: true},
},
},
},
}r, e := slack.New().
WebhookURL(webhookURL).
SendMessage(message)```
Attachments enable markdown```go
// You need get your slack WebhookURL from https://api.slack.com/incoming-webhooks
webhookURL := "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
message := Message{
Attachments: []Attachment{
{Title: "title", MrkdwnIn: []string{"text"},
Fields: []Field{
{Title: "T1", Value: 0, Short: true},
{Title: "T2", Value: 0, Short: true},
},
},
},
}r, e := slack.New().
WebhookURL(webhookURL).
SendMessage(message)```
Debug
```go
// You need get your slack WebhookURL from https://api.slack.com/incoming-webhooks
webhookURL := "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
message := Message{
Text: "message",
}r, e := slack.New().Debug(true).
WebhookURL(webhookURL).
SendMessage(message)