Skip to content

Instantly share code, notes, and snippets.

@rms1000watt
Created March 13, 2019 20:13
Show Gist options
  • Save rms1000watt/011619842708b1c26fa8936fc25d4f88 to your computer and use it in GitHub Desktop.
Save rms1000watt/011619842708b1c26fa8936fc25d4f88 to your computer and use it in GitHub Desktop.
Send Slack Incoming Webhook in Golang
func Slack(url, msg string) (err error) {
buf := bytes.NewBufferString(fmt.Sprintf(`{"text":"%s"}`, msg))
if _, err := http.Post(url, "application/json", buf); err != nil {
fmt.Println("Failed posting to slack:", err)
}
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment