diff --git a/alipay/client.go b/alipay/client.go index ac2bc2f0..68df6215 100644 --- a/alipay/client.go +++ b/alipay/client.go @@ -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)) } diff --git a/alipay/client_request.go b/alipay/client_request.go index 2a9d0e85..5bc3b3cd 100644 --- a/alipay/client_request.go +++ b/alipay/client_request.go @@ -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)) } @@ -142,7 +142,7 @@ 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 != "" { @@ -150,7 +150,7 @@ func (a *Client) doAliPay(ctx context.Context, bm gopay.BodyMap, method string, } } 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") @@ -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") @@ -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") diff --git a/alipay/common_api.go b/alipay/common_api.go index c7d87061..5962f53d 100644 --- a/alipay/common_api.go +++ b/alipay/common_api.go @@ -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") @@ -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 } @@ -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") @@ -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 } @@ -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") diff --git a/alipay/notify.go b/alipay/notify.go index 2721d5ea..dbaa8df8 100644 --- a/alipay/notify.go +++ b/alipay/notify.go @@ -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 { @@ -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 { diff --git a/alipay/sign.go b/alipay/sign.go index 7551db90..6f7d0a00 100644 --- a/alipay/sign.go +++ b/alipay/sign.go @@ -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") @@ -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") diff --git a/paypal/access_token.go b/paypal/access_token.go index 0c71bc8c..c92768fc 100644 --- a/paypal/access_token.go +++ b/paypal/access_token.go @@ -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 diff --git a/paypal/payout.go b/paypal/payout.go index ec2e327d..1157a3d3 100644 --- a/paypal/payout.go +++ b/paypal/payout.go @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/pkg/xhttp/request.go b/pkg/xhttp/request.go index f2326c4f..7f58e48f 100644 --- a/pkg/xhttp/request.go +++ b/pkg/xhttp/request.go @@ -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 { @@ -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) @@ -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 @@ -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 @@ -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: diff --git a/qq/param.go b/qq/param.go index eccbc02e..af7df47a 100644 --- a/qq/param.go +++ b/qq/param.go @@ -147,7 +147,7 @@ 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 @@ -155,12 +155,12 @@ func (q *Client) addCertConfig(certFile, keyFile, pkcs12File any) (tlsConfig *tl 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)...) @@ -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}, diff --git a/qq/payment_api.go b/qq/payment_api.go index 5e5d8b10..22c38901 100644 --- a/qq/payment_api.go +++ b/qq/payment_api.go @@ -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 { @@ -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 } diff --git a/wechat/base_api.go b/wechat/base_api.go index 9d0b4166..862d0080 100644 --- a/wechat/base_api.go +++ b/wechat/base_api.go @@ -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 } @@ -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 } @@ -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 } diff --git a/wechat/param.go b/wechat/param.go index 6a9e2cbb..5ab473e8 100644 --- a/wechat/param.go +++ b/wechat/param.go @@ -105,7 +105,7 @@ 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 @@ -113,12 +113,12 @@ func (w *Client) addCertConfig(certFile, keyFile, pkcs12File any) (tlsConfig *tl 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)...) @@ -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}, diff --git a/wechat/payment_api.go b/wechat/payment_api.go index 4ded7bc3..e47e9956 100644 --- a/wechat/payment_api.go +++ b/wechat/payment_api.go @@ -32,7 +32,7 @@ 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; defer req.Body.Close() if err != nil { - return nil, fmt.Errorf("ioutil.ReadAll:%w", err) + return nil, fmt.Errorf("ioutil.ReadAll: %w", err) } bm = make(gopay.BodyMap) if err = xml.Unmarshal(bs, &bm); err != nil { @@ -48,7 +48,7 @@ func ParseNotify(req *http.Request) (notifyReq *NotifyRequest, err error) { err = xml.NewDecoder(req.Body).Decode(notifyReq) defer req.Body.Close() if err != nil { - return nil, fmt.Errorf("xml.NewDecoder.Decode:%w", err) + return nil, fmt.Errorf("xml.NewDecoder.Decode: %w", err) } return } @@ -62,7 +62,7 @@ func ParseRefundNotify(req *http.Request) (notifyReq *RefundNotifyRequest, err e err = xml.NewDecoder(req.Body).Decode(notifyReq) defer req.Body.Close() if err != nil { - return nil, fmt.Errorf("xml.NewDecoder.Decode:%w", err) + return nil, fmt.Errorf("xml.NewDecoder.Decode: %w", err) } return } diff --git a/wechat/sign.go b/wechat/sign.go index 5ce70def..e9abb1f9 100644 --- a/wechat/sign.go +++ b/wechat/sign.go @@ -37,11 +37,11 @@ func VerifySign(apiKey, signType string, bean any) (ok bool, err error) { bs, err := json.Marshal(bean) if err != nil { - return false, fmt.Errorf("json.Marshal(%s):%w", string(bs), err) + return false, fmt.Errorf("json.Marshal(%s): %w", string(bs), err) } bm := make(gopay.BodyMap) if err = json.Unmarshal(bs, &bm); err != nil { - return false, fmt.Errorf("json.Marshal(%s):%w", string(bs), err) + return false, fmt.Errorf("json.Marshal(%s): %w", string(bs), err) } bodySign := bm.GetString("sign") bm.Remove("sign") diff --git a/wechat/v3/encrypt_decrypt.go b/wechat/v3/encrypt_decrypt.go index 2bb6da8c..a3755928 100644 --- a/wechat/v3/encrypt_decrypt.go +++ b/wechat/v3/encrypt_decrypt.go @@ -22,7 +22,7 @@ func (c *ClientV3) V3EncryptText(text string) (cipherText string, err error) { } cipherByte, err := rsa.EncryptOAEP(sha1.New(), rand.Reader, c.wxPublicKey, []byte(text), nil) if err != nil { - return "", fmt.Errorf("rsa.EncryptOAEP:%w", err) + return "", fmt.Errorf("rsa.EncryptOAEP: %w", err) } return base64.StdEncoding.EncodeToString(cipherByte), nil } @@ -32,7 +32,7 @@ func (c *ClientV3) V3DecryptText(cipherText string) (text string, err error) { cipherByte, _ := base64.StdEncoding.DecodeString(cipherText) textByte, err := rsa.DecryptOAEP(sha1.New(), rand.Reader, c.privateKey, cipherByte, nil) if err != nil { - return "", fmt.Errorf("rsa.DecryptOAEP:%w", err) + return "", fmt.Errorf("rsa.DecryptOAEP: %w", err) } return string(textByte), nil } @@ -46,7 +46,7 @@ func V3EncryptText(text string, wxPublicKeyContent []byte) (cipherText string, e } cipherByte, err := rsa.EncryptOAEP(sha1.New(), rand.Reader, publicKey, []byte(text), nil) if err != nil { - return "", fmt.Errorf("rsa.EncryptOAEP:%w", err) + return "", fmt.Errorf("rsa.EncryptOAEP: %w", err) } return base64.StdEncoding.EncodeToString(cipherByte), nil } @@ -61,7 +61,7 @@ func V3DecryptText(cipherText string, privateKeyContent []byte) (text string, er cipherByte, _ := base64.StdEncoding.DecodeString(cipherText) textByte, err := rsa.DecryptOAEP(sha1.New(), rand.Reader, privateKey, cipherByte, nil) if err != nil { - return "", fmt.Errorf("rsa.DecryptOAEP:%w", err) + return "", fmt.Errorf("rsa.DecryptOAEP: %w", err) } return string(textByte), nil } diff --git a/wechat/v3/notify.go b/wechat/v3/notify.go index 3db10d86..a957c54d 100644 --- a/wechat/v3/notify.go +++ b/wechat/v3/notify.go @@ -325,7 +325,7 @@ func V3ParseNotify(req *http.Request) (notifyReq *V3NotifyReq, err error) { } notifyReq = &V3NotifyReq{SignInfo: si} if err = js.UnmarshalBytes(bs, notifyReq); err != nil { - return nil, fmt.Errorf("json.Unmarshal(%s, %+v):%w", string(bs), notifyReq, err) + return nil, fmt.Errorf("json.Unmarshal(%s, %+v): %w", string(bs), notifyReq, err) } return notifyReq, nil } @@ -574,7 +574,7 @@ func V3ParseNotifyToBodyMap(req *http.Request) (bm gopay.BodyMap, err error) { } bm = make(gopay.BodyMap) if err = js.UnmarshalBytes(bs, &bm); err != nil { - return nil, fmt.Errorf("json.Unmarshal(%s):%w", string(bs), err) + return nil, fmt.Errorf("json.Unmarshal(%s): %w", string(bs), err) } return bm, nil }