1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-06 20:13:50 +08:00

fix selfUpdate() memory usage.

This commit is contained in:
Mrs4s 2021-04-10 16:34:52 +08:00
parent 44539a8f63
commit 67aa9781f2

14
main.go
View File

@ -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)