Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Commit

Permalink
remove result chan
Browse files Browse the repository at this point in the history
  • Loading branch information
freitzzz committed Feb 11, 2023
1 parent 45c5e0d commit a2b4687
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions pkg/telegramwriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ type TelegramWriter struct {
chatId string
}

var resultChan = make(chan *http.Response)

func (tw TelegramWriter) Write(p []byte) (n int, err error) {

body, err := json.Marshal(map[string]string{
Expand All @@ -27,22 +25,19 @@ func (tw TelegramWriter) Write(p []byte) (n int, err error) {

url := fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", tw.botToken)

go asyncPost(url, body, resultChan)
go asyncPost(url, body)

return len(p), nil
}

func asyncPost(url string, body []byte, rc chan *http.Response) {
func asyncPost(url string, body []byte) {
response, err := http.Post(url, messageType, bytes.NewBuffer(body))

if err != nil {
rc <- response
return
}

rc <- response

if response != nil && response.Body != nil {
if response.Body != nil {
response.Body.Close()
}

Expand Down

0 comments on commit a2b4687

Please sign in to comment.