Ai
447 Star 3.2K Fork 1.2K

GVP进击的皇虫/BookStack

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
update.go 803 Bytes
Copy Edit Raw Blame History
TruthHun authored 2018-02-22 15:19 +08:00 . 假装第一次提交
package commands
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"github.com/TruthHun/BookStack/conf"
"github.com/astaxie/beego"
)
//检查最新版本.
func CheckUpdate() {
resp, err := http.Get("https://api.github.com/repos/lifei6671/mindoc/tags")
if err != nil {
beego.Error("CheckUpdate => ", err)
os.Exit(1)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
beego.Error("CheckUpdate => ", err)
os.Exit(1)
}
var result []*struct {
Name string `json:"name"`
}
err = json.Unmarshal(body, &result)
fmt.Println("MinDoc current version => ", conf.VERSION)
if err != nil {
beego.Error("CheckUpdate => ", err)
os.Exit(0)
}
if len(result) > 0 {
fmt.Println("MinDoc last version => ", result[0].Name)
}
os.Exit(0)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/truthhun/BookStack.git
git@gitee.com:truthhun/BookStack.git
truthhun
BookStack
BookStack
v1.3.1

Search