Ver Fonte

feat: 删除 ioutil

kvii há 1 mês atrás
pai
commit
8781970630
2 ficheiros alterados com 14 adições e 13 exclusões
  1. 8 8
      common/lxhttp/http_tax.go
  2. 6 5
      ocr/lx.go

+ 8 - 8
common/lxhttp/http_tax.go

@@ -6,19 +6,19 @@ import (
 	"encoding/base64"
 	"encoding/json"
 	"fmt"
-	login_js "git.listensoft.net/tool/jspkit/common/login-js"
-	"git.listensoft.net/tool/jspkit/logger"
-	"git.listensoft.net/tool/jspkit/taxerr"
-	"github.com/tidwall/gjson"
-	"go.uber.org/zap"
-	"golang.org/x/net/publicsuffix"
 	"io"
-	"io/ioutil"
 	"net/http"
 	"net/http/cookiejar"
 	"net/url"
 	"strings"
 	"time"
+
+	login_js "git.listensoft.net/tool/jspkit/common/login-js"
+	"git.listensoft.net/tool/jspkit/logger"
+	"git.listensoft.net/tool/jspkit/taxerr"
+	"github.com/tidwall/gjson"
+	"go.uber.org/zap"
+	"golang.org/x/net/publicsuffix"
 )
 
 // PostByteReader PostReader 不规则参数 直接传字符串
@@ -186,7 +186,7 @@ n:
 		return nil
 	}
 	defer resp.Body.Close()
-	body, _ := ioutil.ReadAll(resp.Body)
+	body, _ := io.ReadAll(resp.Body)
 	fmt.Println(string(body))
 	Location = resp.Header.Get(`Location`)
 	fmt.Println("Location:", Location)

+ 6 - 5
ocr/lx.go

@@ -2,13 +2,14 @@ package ocr
 
 import (
 	"encoding/base64"
+	"net/http"
+	"os"
+	"time"
+
 	"git.listensoft.net/tool/jspkit/common"
 	"git.listensoft.net/tool/jspkit/common/lxhttp"
 	"github.com/go-kratos/kratos/v2/log"
 	"github.com/tidwall/gjson"
-	"io/ioutil"
-	"net/http"
-	"time"
 )
 
 func GetCaptchaCodeBeijing(imgPath string) string {
@@ -57,14 +58,14 @@ func GetX(captchaPathJpg, captchaPathPng string) float64 {
 func GetXPython(captchaPathJpg, captchaPathPng string) float64 {
 	var encodedJpg, encodedPng string
 	{
-		imgData, err := ioutil.ReadFile(captchaPathJpg)
+		imgData, err := os.ReadFile(captchaPathJpg)
 		if err != nil {
 			log.Fatal(err)
 		}
 
 		// 将图片数据编码为 Base64
 		encodedJpg = base64.StdEncoding.EncodeToString(imgData)
-		imgData, err = ioutil.ReadFile(captchaPathPng)
+		imgData, err = os.ReadFile(captchaPathPng)
 		if err != nil {
 			log.Fatal(err)
 		}