-
-
Save poonai/bb4ea36435ade9fb825655aa6ec071cf to your computer and use it in GitHub Desktop.
helper method to send slack message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package x | |
import ( | |
"os" | |
"github.com/slack-go/slack" | |
"go.uber.org/zap" | |
) | |
var api = slack.New(os.Getenv("SLACK_TOKEN")) | |
//SendSlackMsg is to send msg to slack channel | |
func SendSlackMsg(msg string) { | |
_, _, err := api.PostMessage( | |
os.GetEnv("SLACK_CHANNEL_ID"), // get the channel id by clicking on the slack channel on the top | |
slack.MsgOptionText(msg, false), | |
) | |
Logger.Error("error while sending slack alert", zap.String("err_msg", err.Error()), zap.String("msg", msg)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment