mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-07 04:23:49 +08:00
fix selfUpdate() memory usage.
This commit is contained in:
parent
44539a8f63
commit
67aa9781f2
14
main.go
14
main.go
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
@ -453,22 +452,13 @@ func checkUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func selfUpdate(imageURL string) {
|
func selfUpdate(imageURL string) {
|
||||||
console := bufio.NewReader(os.Stdin)
|
|
||||||
readLine := func() (str string) {
|
|
||||||
str, _ = console.ReadString('\n')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.Infof("正在检查更新.")
|
log.Infof("正在检查更新.")
|
||||||
var res string
|
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)
|
log.Warnf("检查更新失败: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
detail := gjson.Parse(res)
|
info := gjson.Parse(res)
|
||||||
if len(detail.Array()) < 1 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
info := detail.Array()[0]
|
|
||||||
version := info.Get("tag_name").Str
|
version := info.Get("tag_name").Str
|
||||||
if coolq.Version != version {
|
if coolq.Version != version {
|
||||||
log.Info("当前最新版本为 ", version)
|
log.Info("当前最新版本为 ", version)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user