From 50bca808f1157bbf985c469093baa635356b4ee9 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 13 Jun 2023 19:39:24 +0800 Subject: [PATCH] fix --- utils/qrcode/creator.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/utils/qrcode/creator.go b/utils/qrcode/creator.go index 17d616e7..657b2ff2 100644 --- a/utils/qrcode/creator.go +++ b/utils/qrcode/creator.go @@ -31,7 +31,10 @@ func CreateQrCodeBs64WithLogo(content, outPath string, logoPath string, size, x, if x != 0 || y != 0 { draw.Draw(outImg, outImg.Bounds().Add(image.Pt(x, y)), qrcodeImg, outImg.Bounds().Min, draw.Src) } - _ = png.Encode(buf, outImg) + err = png.Encode(buf, outImg) + if err != nil { + return "", err + } if outPath != "" { // 写入文件 f, err := os.Create(outPath) @@ -85,9 +88,15 @@ func CreateQrCodeBs64WithLogo(content, outPath string, logoPath string, size, x, } if outPath != "" { // 写入文件 - f, _ := os.Create(outPath) + f, err := os.Create(outPath) + if err != nil { + return "", err + } defer f.Close() - _ = png.Encode(f, outImg) + err = png.Encode(f, outImg) + if err != nil { + return "", err + } } return base64.StdEncoding.EncodeToString(buf.Bytes()), nil }