diff --git a/README.md b/README.md index bc16250..c666cc0 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Github](https://img.shields.io/github/followers/iGoogle-ink?label=Follow&style=social)](https://github.com/iGoogle-ink) [![Github](https://img.shields.io/github/forks/go-pay/wechat-sdk?label=Fork&style=social)](https://github.com/go-pay/wechat-sdk/fork) -[![Golang](https://img.shields.io/badge/golang-1.18-brightgreen.svg)](https://golang.google.cn) +[![Golang](https://img.shields.io/badge/golang-1.21-brightgreen.svg)](https://golang.google.cn) [![GoDoc](https://img.shields.io/badge/doc-pkg.go.dev-informational.svg)](https://pkg.go.dev/github.com/go-pay/wechat-sdk) [![Go](https://github.com/go-pay/wechat-sdk/actions/workflows/go.yml/badge.svg)](https://github.com/go-pay/wechat-sdk/actions/workflows/go.yml) [![GitHub Release](https://img.shields.io/github/v/release/go-pay/wechat-sdk)](https://github.com/go-pay/wechat-sdk/releases) @@ -26,11 +26,11 @@ go get -u github.com/go-pay/wechat-sdk ```go import ( "github.com/go-pay/wechat-sdk" - "github.com/go-pay/wechat-sdk/pkg/xlog" + "github.com/go-pay/xlog" ) func main() { - xlog.Info("Wechat-SDK Version: ", wechat.Version) + xlog.Warn("Wechat-SDK Version: ", wechat.Version) } ``` @@ -78,4 +78,4 @@ QQ群: > [GoLand](https://www.jetbrains.com/go/?from=gopay) A Go IDE with extended support for JavaScript, TypeScript, and databases。 > 特别感谢 [JetBrains](https://www.jetbrains.com/?from=gopay) 为开源项目提供免费的 [GoLand](https://www.jetbrains.com/go/?from=gopay) 等 IDE 的授权 -[](https://www.jetbrains.com/?from=gopay) \ No newline at end of file +[](https://www.jetbrains.com/?from=gopay) diff --git a/pkg/util/convert.go b/pkg/util/convert.go index 537074d..1e708d9 100644 --- a/pkg/util/convert.go +++ b/pkg/util/convert.go @@ -2,7 +2,6 @@ package util import ( "math" - "reflect" "strconv" "strings" "unsafe" @@ -92,9 +91,5 @@ func BinaryToDecimal(bit string) (num int) { // BytesToString 0 拷贝转换 slice byte 为 string func BytesToString(b []byte) (s string) { - _bptr := (*reflect.SliceHeader)(unsafe.Pointer(&b)) - _sptr := (*reflect.StringHeader)(unsafe.Pointer(&s)) - _sptr.Data = _bptr.Data - _sptr.Len = _bptr.Len - return s + return *(*string)(unsafe.Pointer(&b)) } diff --git a/pkg/xhttp/client.go b/pkg/xhttp/client.go index 60d4113..d25bc6f 100644 --- a/pkg/xhttp/client.go +++ b/pkg/xhttp/client.go @@ -9,7 +9,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "mime/multipart" "net/http" "net/url" @@ -304,7 +303,7 @@ func (c *Client) EndBytes(ctx context.Context) (res *http.Response, bs []byte, e return err } defer res.Body.Close() - bs, err = ioutil.ReadAll(io.LimitReader(res.Body, int64(5<<20))) // default 5MB change the size you want + bs, err = io.ReadAll(io.LimitReader(res.Body, int64(5<<20))) // default 5MB change the size you want if err != nil { return err } diff --git a/pkg/xhttp/client_test.go b/pkg/xhttp/client_test.go index f12d8a9..15a77c5 100644 --- a/pkg/xhttp/client_test.go +++ b/pkg/xhttp/client_test.go @@ -2,7 +2,7 @@ package xhttp import ( "context" - "io/ioutil" + "os" "testing" "time" @@ -40,7 +40,7 @@ func TestHttpGet(t *testing.T) { } func TestHttpUploadFile(t *testing.T) { - fileContent, err := ioutil.ReadFile("../../logo.png") + fileContent, err := os.ReadFile("../../logo.png") if err != nil { xlog.Error(err) return