Skip to content

Commit

Permalink
fix incorrect uses of Chinese commas (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
Laotree authored Dec 11, 2024
1 parent 0225abe commit 4e44179
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 57 deletions.
2 changes: 1 addition & 1 deletion alipay/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (a *Client) RequestParam(bm gopay.BodyMap, method string) (string, error) {
bz := bm.GetAny("biz_content")
if bzBody, ok := bz.(gopay.BodyMap); ok {
if bodyBs, err = json.Marshal(bzBody); err != nil {
return "", fmt.Errorf("json.Marshal(%v)%w", bzBody, err)
return "", fmt.Errorf("json.Marshal(%v): %w", bzBody, err)
}
bm.Set("biz_content", string(bodyBs))
}
Expand Down
14 changes: 7 additions & 7 deletions alipay/client_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (a *Client) PostAliPayAPISelfV2(ctx context.Context, bodyMap gopay.BodyMap,
bz := bodyMap.GetAny("biz_content")
if bzBody, ok := bz.(gopay.BodyMap); ok {
if bodyBs, err = json.Marshal(bzBody); err != nil {
return fmt.Errorf("json.Marshal(%v)%w", bzBody, err)
return fmt.Errorf("json.Marshal(%v): %w", bzBody, err)
}
bodyMap.Set("biz_content", string(bodyBs))
}
Expand Down Expand Up @@ -142,15 +142,15 @@ func (a *Client) doAliPay(ctx context.Context, bm gopay.BodyMap, method string,
aat := bm.GetString("app_auth_token")
bm.Remove("app_auth_token")
if bodyBs, err = json.Marshal(bm); err != nil {
return nil, fmt.Errorf("json.Marshal%w", err)
return nil, fmt.Errorf("json.Marshal: %w", err)
}
bizContent = string(bodyBs)
if aat != "" {
bm.Set("app_auth_token", aat)
}
} else {
if bodyBs, err = json.Marshal(bm); err != nil {
return nil, fmt.Errorf("json.Marshal%w", err)
return nil, fmt.Errorf("json.Marshal: %w", err)
}
bizContent = string(bodyBs)
bm.Remove("app_auth_token")
Expand Down Expand Up @@ -200,13 +200,13 @@ func (a *Client) DoAliPay(ctx context.Context, bm gopay.BodyMap, method string,
aat := bm.GetString("app_auth_token")
bm.Remove("app_auth_token")
if bodyBs, err = json.Marshal(bm); err != nil {
return nil, fmt.Errorf("json.Marshal%w", err)
return nil, fmt.Errorf("json.Marshal: %w", err)
}
bizContent = string(bodyBs)
bm.Set("app_auth_token", aat)
} else {
if bodyBs, err = json.Marshal(bm); err != nil {
return nil, fmt.Errorf("json.Marshal%w", err)
return nil, fmt.Errorf("json.Marshal: %w", err)
}
bizContent = string(bodyBs)
bm.Remove("app_auth_token")
Expand Down Expand Up @@ -256,13 +256,13 @@ func (a *Client) PageExecute(ctx context.Context, bm gopay.BodyMap, method strin
aat := bm.GetString("app_auth_token")
bm.Remove("app_auth_token")
if bodyBs, err = json.Marshal(bm); err != nil {
return "", fmt.Errorf("json.Marshal%w", err)
return "", fmt.Errorf("json.Marshal: %w", err)
}
bizContent = string(bodyBs)
bm.Set("app_auth_token", aat)
} else {
if bodyBs, err = json.Marshal(bm); err != nil {
return "", fmt.Errorf("json.Marshal%w", err)
return "", fmt.Errorf("json.Marshal: %w", err)
}
bizContent = string(bodyBs)
bm.Remove("app_auth_token")
Expand Down
10 changes: 5 additions & 5 deletions alipay/common_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func DecryptOpenDataToStruct(encryptedData, secretKey string, beanPtr any) (err
ivKey := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
secretData, _ := base64.StdEncoding.DecodeString(encryptedData)
if block, err = aes.NewCipher(aesKey); err != nil {
return fmt.Errorf("aes.NewCipher%w", err)
return fmt.Errorf("aes.NewCipher: %w", err)
}
if len(secretData)%len(aesKey) != 0 {
return errors.New("encryptedData is error")
Expand All @@ -67,7 +67,7 @@ func DecryptOpenDataToStruct(encryptedData, secretKey string, beanPtr any) (err
originData = xaes.PKCS5UnPadding(originData)
}
if err = json.Unmarshal(originData, beanPtr); err != nil {
return fmt.Errorf("json.Unmarshal(%s)%w", string(originData), err)
return fmt.Errorf("json.Unmarshal(%s): %w", string(originData), err)
}
return nil
}
Expand All @@ -89,7 +89,7 @@ func DecryptOpenDataToBodyMap(encryptedData, secretKey string) (bm gopay.BodyMap
aesKey, _ = base64.StdEncoding.DecodeString(secretKey)
secretData, _ := base64.StdEncoding.DecodeString(encryptedData)
if block, err = aes.NewCipher(aesKey); err != nil {
return nil, fmt.Errorf("aes.NewCipher%w", err)
return nil, fmt.Errorf("aes.NewCipher: %w", err)
}
if len(secretData)%len(aesKey) != 0 {
return nil, errors.New("encryptedData is error")
Expand All @@ -102,7 +102,7 @@ func DecryptOpenDataToBodyMap(encryptedData, secretKey string) (bm gopay.BodyMap
}
bm = make(gopay.BodyMap)
if err = json.Unmarshal(originData, &bm); err != nil {
return nil, fmt.Errorf("json.Unmarshal(%s)%w", string(originData), err)
return nil, fmt.Errorf("json.Unmarshal(%s): %w", string(originData), err)
}
return
}
Expand Down Expand Up @@ -143,7 +143,7 @@ func SystemOauthToken(ctx context.Context, appId string, privateKey, grantType,
}
rsp = new(SystemOauthTokenResponse)
if err = json.Unmarshal(bs, rsp); err != nil {
return nil, fmt.Errorf("json.Unmarshal(%s)%w", string(bs), err)
return nil, fmt.Errorf("json.Unmarshal(%s): %w", string(bs), err)
}
if (rsp.Response == nil) || (rsp.Response != nil && rsp.Response.AccessToken == "") {
return nil, errors.New("response is nil or access_token is NULL")
Expand Down
4 changes: 2 additions & 2 deletions alipay/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func ParseNotifyResult(req *http.Request) (notifyReq *NotifyRequest, err error)
if billList != gopay.NULL {
bills := make([]*FundBillListInfo, 0)
if err = json.Unmarshal([]byte(billList), &bills); err != nil {
return nil, fmt.Errorf(`"fund_bill_list" json.Unmarshal(%s)%w`, billList, err)
return nil, fmt.Errorf(`"fund_bill_list" json.Unmarshal(%s): %w`, billList, err)
}
notifyReq.FundBillList = bills
} else {
Expand All @@ -101,7 +101,7 @@ func ParseNotifyResult(req *http.Request) (notifyReq *NotifyRequest, err error)
if detailList != gopay.NULL {
details := make([]*NotifyVoucherDetail, 0)
if err = json.Unmarshal([]byte(detailList), &details); err != nil {
return nil, fmt.Errorf(`"voucher_detail_list" json.Unmarshal(%s)%w`, detailList, err)
return nil, fmt.Errorf(`"voucher_detail_list" json.Unmarshal(%s): %w`, detailList, err)
}
notifyReq.VoucherDetailList = details
} else {
Expand Down
8 changes: 4 additions & 4 deletions alipay/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,10 @@ func VerifySign(alipayPublicKey string, notifyBean any) (ok bool, err error) {
} else {
bs, err := json.Marshal(notifyBean)
if err != nil {
return false, fmt.Errorf("json.Marshal%w", err)
return false, fmt.Errorf("json.Marshal: %w", err)
}
if err = json.Unmarshal(bs, &bm); err != nil {
return false, fmt.Errorf("json.Unmarshal(%s)%w", string(bs), err)
return false, fmt.Errorf("json.Unmarshal(%s): %w", string(bs), err)
}
bodySign = bm.GetString("sign")
bodySignType = bm.GetString("sign_type")
Expand Down Expand Up @@ -379,10 +379,10 @@ func VerifySignWithCert(aliPayPublicKeyCert, notifyBean any) (ok bool, err error
default:
bs, err := json.Marshal(notifyBean)
if err != nil {
return false, fmt.Errorf("json.Marshal%w", err)
return false, fmt.Errorf("json.Marshal: %w", err)
}
if err = json.Unmarshal(bs, &bm); err != nil {
return false, fmt.Errorf("json.Unmarshal(%s)%w", string(bs), err)
return false, fmt.Errorf("json.Unmarshal(%s): %w", string(bs), err)
}
}
bodySign := bm.GetString("sign")
Expand Down
2 changes: 1 addition & 1 deletion paypal/access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (c *Client) GetAccessToken() (token *AccessToken, err error) {
}
token = new(AccessToken)
if err = json.Unmarshal(bs, token); err != nil {
return nil, fmt.Errorf("json.Unmarshal(%s)%w", string(bs), err)
return nil, fmt.Errorf("json.Unmarshal(%s): %w", string(bs), err)
}
c.Appid = token.Appid
c.AccessToken = token.AccessToken
Expand Down
8 changes: 4 additions & 4 deletions paypal/payout.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (c *Client) CreateBatchPayout(ctx context.Context, bm gopay.BodyMap) (ppRsp
ppRsp = &CreateBatchPayoutRsp{Code: Success}
ppRsp.Response = new(BatchPayout)
if err = json.Unmarshal(bs, ppRsp.Response); nil != err {
return nil, fmt.Errorf("json.Unmarshal(%s)%w", string(bs), err)
return nil, fmt.Errorf("json.Unmarshal(%s): %w", string(bs), err)
}
if res.StatusCode != http.StatusCreated {
ppRsp.Code = res.StatusCode
Expand All @@ -54,7 +54,7 @@ func (c *Client) ShowPayoutBatchDetails(ctx context.Context, payoutBatchId strin
ppRsp = &PayoutBatchDetailRsp{Code: Success}
ppRsp.Response = new(PayoutBatchDetail)
if err = json.Unmarshal(bs, ppRsp.Response); err != nil {
return nil, fmt.Errorf("json.Unmarshal(%s)%w", string(bs), err)
return nil, fmt.Errorf("json.Unmarshal(%s): %w", string(bs), err)
}
if res.StatusCode != http.StatusOK {
ppRsp.Code = res.StatusCode
Expand All @@ -80,7 +80,7 @@ func (c Client) ShowPayoutItemDetails(ctx context.Context, payoutItemId string)
ppRsp = &PayoutItemDetailRsp{Code: Success}
ppRsp.Response = new(PayoutItemDetail)
if err = json.Unmarshal(bs, ppRsp.Response); err != nil {
return nil, fmt.Errorf("json.Unmarshal(%s)%w", string(bs), err)
return nil, fmt.Errorf("json.Unmarshal(%s): %w", string(bs), err)
}
if res.StatusCode != http.StatusOK {
ppRsp.Code = res.StatusCode
Expand All @@ -106,7 +106,7 @@ func (c Client) CancelUnclaimedPayoutItem(ctx context.Context, payoutItemId stri
ppRsp = &CancelUnclaimedPayoutItemRsp{Code: Success}
ppRsp.Response = new(PayoutItemDetail)
if err = json.Unmarshal(bs, ppRsp.Response); err != nil {
return nil, fmt.Errorf("json.Unmarshal(%s)%w", string(bs), err)
return nil, fmt.Errorf("json.Unmarshal(%s): %w", string(bs), err)
}
if res.StatusCode != http.StatusOK {
ppRsp.Code = res.StatusCode
Expand Down
12 changes: 6 additions & 6 deletions pkg/xhttp/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (r *Request) SendStruct(v any) (c *Request) {
}
bs, err := json.Marshal(v)
if err != nil {
r.err = fmt.Errorf("json.Marshal(%+v)%w", v, err)
r.err = fmt.Errorf("json.Marshal(%+v): %w", v, err)
return r
}
switch r.requestType {
Expand All @@ -81,7 +81,7 @@ func (r *Request) SendStruct(v any) (c *Request) {
case TypeXML, TypeFormData:
body := make(map[string]any)
if err = json.Unmarshal(bs, &body); err != nil {
r.err = fmt.Errorf("json.Unmarshal(%s, %+v)%w", string(bs), body, err)
r.err = fmt.Errorf("json.Unmarshal(%s, %+v): %w", string(bs), body, err)
return r
}
r.formString = FormatURLParam(body)
Expand All @@ -97,7 +97,7 @@ func (r *Request) SendBodyMap(bm map[string]any) (client *Request) {
case TypeJSON:
bs, err := json.Marshal(bm)
if err != nil {
r.err = fmt.Errorf("json.Marshal(%+v)%w", bm, err)
r.err = fmt.Errorf("json.Marshal(%+v): %w", bm, err)
return r
}
r.jsonByte = bs
Expand All @@ -115,7 +115,7 @@ func (r *Request) SendMultipartBodyMap(bm map[string]any) (client *Request) {
case TypeJSON:
bs, err := json.Marshal(bm)
if err != nil {
r.err = fmt.Errorf("json.Marshal(%+v)%w", bm, err)
r.err = fmt.Errorf("json.Marshal(%+v): %w", bm, err)
return r
}
r.jsonByte = bs
Expand Down Expand Up @@ -307,13 +307,13 @@ func (r *Request) EndStruct(ctx context.Context, v any) (res *http.Response, err
case ResTypeJSON:
err = json.Unmarshal(bs, &v)
if err != nil {
return nil, fmt.Errorf("json.Unmarshal(%s, %+v)%w", string(bs), v, err)
return nil, fmt.Errorf("json.Unmarshal(%s, %+v): %w", string(bs), v, err)
}
return res, nil
case ResTypeXML:
err = xml.Unmarshal(bs, &v)
if err != nil {
return nil, fmt.Errorf("xml.Unmarshal(%s, %+v)%w", string(bs), v, err)
return nil, fmt.Errorf("xml.Unmarshal(%s, %+v): %w", string(bs), v, err)
}
return res, nil
default:
Expand Down
8 changes: 4 additions & 4 deletions qq/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,20 @@ func (q *Client) addCertConfig(certFile, keyFile, pkcs12File any) (tlsConfig *tl
keyPem, err = os.ReadFile(keyFile.(string))
}
if err != nil {
return nil, fmt.Errorf("os.ReadFile%w", err)
return nil, fmt.Errorf("os.ReadFile: %w", err)
}
} else if pkcs12File != nil {
var pfxData []byte
if _, ok := pkcs12File.([]byte); ok {
pfxData = pkcs12File.([]byte)
} else {
if pfxData, err = os.ReadFile(pkcs12File.(string)); err != nil {
return nil, fmt.Errorf("os.ReadFile%w", err)
return nil, fmt.Errorf("os.ReadFile: %w", err)
}
}
blocks, err := pkcs12.ToPEM(pfxData, q.MchId)
if err != nil {
return nil, fmt.Errorf("pkcs12.ToPEM%w", err)
return nil, fmt.Errorf("pkcs12.ToPEM: %w", err)
}
for _, b := range blocks {
keyPem = append(keyPem, pem.EncodeToMemory(b)...)
Expand All @@ -169,7 +169,7 @@ func (q *Client) addCertConfig(certFile, keyFile, pkcs12File any) (tlsConfig *tl
}
if certPem != nil && keyPem != nil {
if certificate, err = tls.X509KeyPair(certPem, keyPem); err != nil {
return nil, fmt.Errorf("tls.LoadX509KeyPair%w", err)
return nil, fmt.Errorf("tls.LoadX509KeyPair: %w", err)
}
tlsConfig = &tls.Config{
Certificates: []tls.Certificate{certificate},
Expand Down
4 changes: 2 additions & 2 deletions qq/payment_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
func ParseNotifyToBodyMap(req *http.Request) (bm gopay.BodyMap, err error) {
bs, err := io.ReadAll(io.LimitReader(req.Body, int64(3<<20))) // default 3MB change the size you want;
if err != nil {
return nil, fmt.Errorf("io.ReadAll%w", err)
return nil, fmt.Errorf("io.ReadAll: %w", err)
}
bm = make(gopay.BodyMap)
if err = xml.Unmarshal(bs, &bm); err != nil {
Expand All @@ -39,7 +39,7 @@ func ParseNotifyToBodyMap(req *http.Request) (bm gopay.BodyMap, err error) {
func ParseNotify(req *http.Request) (notifyReq *NotifyRequest, err error) {
notifyReq = new(NotifyRequest)
if err = xml.NewDecoder(req.Body).Decode(notifyReq); err != nil {
return nil, fmt.Errorf("xml.NewDecoder.Decode%w", err)
return nil, fmt.Errorf("xml.NewDecoder.Decode: %w", err)
}
return
}
Expand Down
12 changes: 6 additions & 6 deletions wechat/base_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ func (w *Client) QueryOrder(ctx context.Context, bm gopay.BodyMap) (wxRsp *Query
}
wxRsp = new(QueryOrderResponse)
if err = xml.Unmarshal(bs, wxRsp); err != nil {
return nil, nil, fmt.Errorf("xml.UnmarshalStruct(%s)%w", string(bs), err)
return nil, nil, fmt.Errorf("xml.UnmarshalStruct(%s): %w", string(bs), err)
}
resBm = make(gopay.BodyMap)
if err = xml.Unmarshal(bs, &resBm); err != nil {
return nil, nil, fmt.Errorf("xml.UnmarshalBodyMap(%s)%w", string(bs), err)
return nil, nil, fmt.Errorf("xml.UnmarshalBodyMap(%s): %w", string(bs), err)
}
return wxRsp, resBm, nil
}
Expand Down Expand Up @@ -139,11 +139,11 @@ func (w *Client) Refund(ctx context.Context, bm gopay.BodyMap) (wxRsp *RefundRes
}
wxRsp = new(RefundResponse)
if err = xml.Unmarshal(bs, wxRsp); err != nil {
return nil, nil, fmt.Errorf("xml.UnmarshalStruct(%s)%w", string(bs), err)
return nil, nil, fmt.Errorf("xml.UnmarshalStruct(%s): %w", string(bs), err)
}
resBm = make(gopay.BodyMap)
if err = xml.Unmarshal(bs, &resBm); err != nil {
return nil, nil, fmt.Errorf("xml.UnmarshalBodyMap(%s)%w", string(bs), err)
return nil, nil, fmt.Errorf("xml.UnmarshalBodyMap(%s): %w", string(bs), err)
}
return wxRsp, resBm, nil
}
Expand All @@ -170,11 +170,11 @@ func (w *Client) QueryRefund(ctx context.Context, bm gopay.BodyMap) (wxRsp *Quer
}
wxRsp = new(QueryRefundResponse)
if err = xml.Unmarshal(bs, wxRsp); err != nil {
return nil, nil, fmt.Errorf("xml.UnmarshalStruct(%s)%w", string(bs), err)
return nil, nil, fmt.Errorf("xml.UnmarshalStruct(%s): %w", string(bs), err)
}
resBm = make(gopay.BodyMap)
if err = xml.Unmarshal(bs, &resBm); err != nil {
return nil, nil, fmt.Errorf("xml.UnmarshalBodyMap(%s)%w", string(bs), err)
return nil, nil, fmt.Errorf("xml.UnmarshalBodyMap(%s): %w", string(bs), err)
}
return wxRsp, resBm, nil
}
Expand Down
8 changes: 4 additions & 4 deletions wechat/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,20 @@ func (w *Client) addCertConfig(certFile, keyFile, pkcs12File any) (tlsConfig *tl
keyPem, err = os.ReadFile(keyFile.(string))
}
if err != nil {
return nil, fmt.Errorf("os.ReadFile%w", err)
return nil, fmt.Errorf("os.ReadFile: %w", err)
}
} else if pkcs12File != nil {
var pfxData []byte
if _, ok := pkcs12File.([]byte); ok {
pfxData = pkcs12File.([]byte)
} else {
if pfxData, err = os.ReadFile(pkcs12File.(string)); err != nil {
return nil, fmt.Errorf("os.ReadFile%w", err)
return nil, fmt.Errorf("os.ReadFile: %w", err)
}
}
blocks, err := pkcs12.ToPEM(pfxData, w.MchId)
if err != nil {
return nil, fmt.Errorf("pkcs12.ToPEM%w", err)
return nil, fmt.Errorf("pkcs12.ToPEM: %w", err)
}
for _, b := range blocks {
keyPem = append(keyPem, pem.EncodeToMemory(b)...)
Expand All @@ -127,7 +127,7 @@ func (w *Client) addCertConfig(certFile, keyFile, pkcs12File any) (tlsConfig *tl
}
if certPem != nil && keyPem != nil {
if certificate, err = tls.X509KeyPair(certPem, keyPem); err != nil {
return nil, fmt.Errorf("tls.LoadX509KeyPair%w", err)
return nil, fmt.Errorf("tls.LoadX509KeyPair: %w", err)
}
tlsConfig = &tls.Config{
Certificates: []tls.Certificate{certificate},
Expand Down
Loading

0 comments on commit 4e44179

Please sign in to comment.