chore: use fmt.Errorf(...) instead of errors.New(fmt.Sprintf(...))

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
dependabot/npm_and_yarn/static/table-editor/word-wrap-1.2.4
guangwu 2023-07-07 11:00:36 +08:00 committed by GitHub
parent cc34c6309e
commit 06e7b0ab70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 8 deletions

View File

@ -20,7 +20,6 @@ import (
beegoCache "github.com/beego/beego/v2/client/cache"
_ "github.com/beego/beego/v2/client/cache/memcache"
"github.com/beego/beego/v2/client/cache/redis"
_ "github.com/beego/beego/v2/client/cache/redis"
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs"
"github.com/beego/beego/v2/server/web"

View File

@ -201,7 +201,7 @@ func (m *Member) ldapLogin(account string, password string) (*Member, error) {
if len(m.Email) > 0 {
// 如果member配置的email和ldap配置的email不同
if m.Email != ldap_mail {
return m, errors.New(fmt.Sprintf("ldap配置的email(%s)与数据库中已有email({%s})不同, 请联系管理员修改", ldap_mail, m.Email))
return m, fmt.Errorf("ldap配置的email(%s)与数据库中已有email({%s})不同, 请联系管理员修改", ldap_mail, m.Email)
}
} else {
// 如果member未配置email则用ldap的email配置

View File

@ -62,7 +62,7 @@ func (d *DingTalkAgent) GetUserIDByCode(code string) (string, error) {
errcode := rdata["errcode"].(float64)
if errcode != 0 {
return "", errors.New(fmt.Sprintf("登录错误: %.0f, %s", errcode, rdata["errmsg"].(string)))
return "", fmt.Errorf("登录错误: %.0f, %s", errcode, rdata["errmsg"].(string))
}
userid := rdata["userid"].(string)
@ -100,7 +100,7 @@ func (d *DingTalkAgent) GetUserNameAndAvatarByUserID(userid string) (string, str
errcode := rdata["errcode"].(float64)
if errcode != 0 {
return "", "", errors.New(fmt.Sprintf("登录错误: %.0f, %s", errcode, rdata["errmsg"].(string)))
return "", "", fmt.Errorf("登录错误: %.0f, %s", errcode, rdata["errmsg"].(string))
}
userinfo := rdata["result"].(map[string]interface{})
@ -138,7 +138,7 @@ func (d *DingTalkAgent) GetUserIDByUnionID(unionid string) (string, error) {
errcode := rdata["errcode"].(float64)
if errcode != 0 {
return "", errors.New(fmt.Sprintf("登录错误: %.0f, %s", errcode, rdata["errmsg"].(string)))
return "", fmt.Errorf("登录错误: %.0f, %s", errcode, rdata["errmsg"].(string))
}
result := rdata["result"].(map[string]interface{})
@ -224,7 +224,7 @@ func (d *DingtalkQRLogin) GetUnionIDByCode(code string) (userid string, err erro
}
errcode := rdata["errcode"].(float64)
if errcode != 0 {
return "", errors.New(fmt.Sprintf("登录错误: %.0f, %s", errcode, rdata["errmsg"].(string)))
return "", fmt.Errorf("登录错误: %.0f, %s", errcode, rdata["errmsg"].(string))
}
unionid := rdata["user_info"].(map[string]interface{})["unionid"].(string)
return unionid, nil

View File

@ -5,7 +5,6 @@ import (
"net/http"
"net/url"
"os"
"errors"
"fmt"
)
@ -39,7 +38,7 @@ func DownloadAndSaveFile(remoteUrl, dstFile string) (error) {
if resp.StatusCode == http.StatusOK {
_, err = io.Copy(out, resp.Body)
}else{
return errors.New(fmt.Sprintf("bad status: %s", resp.Status))
return fmt.Errorf("bad status: %s", resp.Status)
}
return nil
}