A Golang package for alerts using Slack.
go get github.com/takuoki/slack-alert/slacka
client := slacka.New("username", "service name", "icon url")
client.SetURL("URL_KEY1", "https://hooks.slack.com/services/xxx/xxx/xxxxx")
client.SetURL("URL_KEY2", "https://hooks.slack.com/services/yyy/yyy/yyyyy")
client.SetErrorURL("https://hooks.slack.com/services/zzz/zzz/zzzzz")
err := client.Send("URL_KEY1", "This is message!")
You can change username
and icon url
with options.
err := client.Send("URL_KEY1", "This is message!",
slacka.WebhookUsername("new username"),
slacka.WebhookIconURL("new icon url"))
Every method has a method of format type like Debugf
.
// Debug
err := client.Debug("This is message!")
// Info
err := client.Info("This is message!")
// Warn
err := client.Warn("This is message!")
// Error
err := client.Error("This is message!")
// Fatal
err := client.Fatal("This is message!")