Replace ioutil.ReadAll with io.ReadAll in Image
model
This commit is contained in:
@@ -3,7 +3,6 @@ package models
|
||||
import (
|
||||
"image"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"regexp"
|
||||
@@ -39,7 +38,8 @@ func (img *Image) Init(content string) (err error) {
|
||||
// 判断图片格式是否为 gif 或 GIF
|
||||
if len(regexp.MustCompile(`\.gif$`).FindStringSubmatch(key)) > 0 {
|
||||
img.format = "gif"
|
||||
img.data, err = ioutil.ReadAll(body)
|
||||
img.data, err = io.ReadAll(body)
|
||||
|
||||
if err != nil {
|
||||
log.Println("读取图片失败", err)
|
||||
return
|
||||
@@ -67,7 +67,7 @@ func (img *Image) Init(content string) (err error) {
|
||||
// 判断图片格式是否为 gif 或 GIF
|
||||
if len(regexp.MustCompile(`\.gif$`).FindStringSubmatch(content)) > 0 {
|
||||
img.format = "gif"
|
||||
img.data, err = ioutil.ReadAll(resp.Body)
|
||||
img.data, err = io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Println("读取图片失败", err)
|
||||
return
|
||||
|
Reference in New Issue
Block a user