From b6a688b1d0d40bd5c114fb9dabe838eb0d789129 Mon Sep 17 00:00:00 2001 From: Matthias Loibl Date: Tue, 8 Aug 2017 12:28:04 +0200 Subject: [PATCH] Add missing godoc comments and actually use the context for the request --- slack.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/slack.go b/slack.go index d83cc46..af1ab13 100644 --- a/slack.go +++ b/slack.go @@ -10,6 +10,7 @@ import ( "time" ) +// SlackSender has the hook to send slack notifications. type SlackSender struct { Hook string } @@ -20,6 +21,7 @@ type slackPayload struct { Text string `json:"text"` } +// Send a notification with a formatted message build from the repository. func (s *SlackSender) Send(repository Repository) error { payload := slackPayload{ Username: "GitHub Releases", @@ -43,9 +45,9 @@ func (s *SlackSender) Send(repository Repository) error { if err != nil { return err } - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Millisecond) + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + req = req.WithContext(ctx) defer cancel() - req.WithContext(ctx) resp, err := http.DefaultClient.Do(req) if err != nil {