A simple, flexible Golang wrapper around the Slack webhook API. Makes it easy to send notifications to Slack from your application(inspired by nodejs slack-notify).
- Send plain text and message with attachments
- Send attachments with markdown syntax
- Debug
- Timeout
- Logger
- Context(todo)
$ go get -u github.com/easonlin404/go-slack
Basic send text message
// 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
// 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
// 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
// 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)