mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: update golangci-lint config
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user