chore: update golangci-lint config

This commit is contained in:
Steven
2023-09-17 22:55:13 +08:00
parent 9eb077c4af
commit cd0ea6558d
72 changed files with 272 additions and 187 deletions

View File

@@ -3,10 +3,11 @@ package telegram
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"github.com/pkg/errors"
)
func (b *Bot) postForm(ctx context.Context, apiPath string, formData url.Values, result any) error {
@@ -17,13 +18,13 @@ func (b *Bot) postForm(ctx context.Context, apiPath string, formData url.Values,
resp, err := http.PostForm(apiURL+apiPath, formData)
if err != nil {
return fmt.Errorf("fail to http.PostForm: %s", err)
return errors.Wrap(err, "fail to http.PostForm")
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("fail to ioutil.ReadAll: %s", err)
return errors.Wrap(err, "fail to ioutil.ReadAll")
}
var respInfo struct {
@@ -37,11 +38,11 @@ func (b *Bot) postForm(ctx context.Context, apiPath string, formData url.Values,
err = json.Unmarshal(body, &respInfo)
if err != nil {
return fmt.Errorf("fail to json.Unmarshal: %s", err)
return errors.Wrap(err, "fail to json.Unmarshal")
}
if !respInfo.Ok {
return fmt.Errorf("api error: [%d]%s", respInfo.ErrorCode, respInfo.Description)
return errors.Errorf("api error: [%d]%s", respInfo.ErrorCode, respInfo.Description)
}
return nil