package main import ( "bytes" "encoding/json" "errors" "io/ioutil" "log" ) func sendMessage(responseUrl, origText, text string) error { jm := message{ Text: origText, //ResponseType: "in_channel", Attachments: []Attachment{{Text: text, Color: "#36a64f"}}, } b, _ := json.Marshal(jm) resp, err := getClient().Post(responseUrl, "application/json", bytes.NewReader(b)) if err != nil { log.Println(err) return err } defer resp.Body.Close() s, _ := ioutil.ReadAll(resp.Body) if resp.StatusCode >= 300 || resp.StatusCode < 200 { log.Println("unexpected status " + resp.Status) log.Println(string(s)) return errors.New("unexpected status " + resp.Status) } return nil }