fix: lint errors
This commit is contained in:
parent
abcd3c3c44
commit
763a451251
10 changed files with 91 additions and 55 deletions
|
@ -4,7 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -37,11 +37,15 @@ func (s *SlackPlatform) Init(_ *config.Config) error {
|
|||
// ParseIncomingMessage parses an incoming Slack message
|
||||
func (s *SlackPlatform) ParseIncomingMessage(r *http.Request) (*model.Message, error) {
|
||||
// Read request body
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer r.Body.Close()
|
||||
defer func() {
|
||||
if err := r.Body.Close(); err != nil {
|
||||
fmt.Printf("Error closing request body: %v\n", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// Parse JSON
|
||||
var requestData map[string]interface{}
|
||||
|
@ -194,7 +198,11 @@ func (s *SlackPlatform) SendMessage(msg *model.Message) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer func() {
|
||||
if err := resp.Body.Close(); err != nil {
|
||||
fmt.Printf("Error closing response body: %v\n", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// Check response
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
|
@ -209,4 +217,4 @@ func parseInt64(s string) (int64, error) {
|
|||
var n int64
|
||||
_, err := fmt.Sscanf(s, "%d", &n)
|
||||
return n, err
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue