From 67aa9781f2a492a81e4852529ea02c915860dbb7 Mon Sep 17 00:00:00 2001 From: Mrs4s <1844812067@qq.com> Date: Sat, 10 Apr 2021 16:34:52 +0800 Subject: [PATCH] fix selfUpdate() memory usage. --- main.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index c8a3b14..ef3004a 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "bufio" "crypto/aes" "crypto/md5" "crypto/sha1" @@ -453,22 +452,13 @@ func checkUpdate() { } func selfUpdate(imageURL string) { - console := bufio.NewReader(os.Stdin) - readLine := func() (str string) { - str, _ = console.ReadString('\n') - return - } log.Infof("正在检查更新.") var res string - if err := gout.GET("https://api.github.com/repos/Mrs4s/go-cqhttp/releases").BindBody(&res).Do(); err != nil { + if err := gout.GET("https://api.github.com/repos/Mrs4s/go-cqhttp/releases/latest").BindBody(&res).Do(); err != nil { log.Warnf("检查更新失败: %v", err) return } - detail := gjson.Parse(res) - if len(detail.Array()) < 1 { - return - } - info := detail.Array()[0] + info := gjson.Parse(res) version := info.Get("tag_name").Str if coolq.Version != version { log.Info("当前最新版本为 ", version)