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