Documentation ¶
Overview ¶
Package slack provide a simple API for sending message to Slack using only standard packages.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PostWebhook ¶
PostWebhook send a message using "Incoming Webhook".
Example ¶
webhookURL := os.Getenv("SLACK_WEBHOOK_URL") if len(webhookURL) == 0 { return } msg := &Message{ Channel: "test", Username: "Test", IconEmoji: ":ghost:", Text: "Hello, world!", } err := PostWebhook(webhookURL, msg) if err != nil { log.Fatal(err) }
Output:
Types ¶
type Message ¶
type Message struct { Channel string `json:"channel,omitempty"` Username string `json:"username,omitempty"` IconEmoji string `json:"icon_emoji,omitempty"` IconURL string `json:"icon_url,omitempty"` Text string `json:"text"` }
Message define the standard message payload with JSON tags.
type WebhookClient ¶
WebhookClient for slack. Use this for long running program that post message every minutes or seconds.
func NewWebhookClient ¶
func NewWebhookClient(webhookURL, user, channel string) (wcl *WebhookClient, err error)
NewWebhookClient create new slack client that will write the message using webhook URL and optional user and channel.
func (*WebhookClient) Close ¶
func (wcl *WebhookClient) Close() (err error)
Close the client connection.
func (*WebhookClient) Post ¶
func (wcl *WebhookClient) Post(msg *Message) (err error)
Post the Message as is.
Click to show internal directories.
Click to hide internal directories.