当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
109 Star 473 Fork 186

Minho / mindoc
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
update.go 801 Bytes
一键复制 编辑 原始数据 按行查看 历史
Minho 提交于 2017-06-14 09:26 . *
package commands
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"github.com/astaxie/beego"
"github.com/lifei6671/mindoc/conf"
)
//检查最新版本.
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)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/longfei6671/godoc.git
git@gitee.com:longfei6671/godoc.git
longfei6671
godoc
mindoc
v0.10.1

搜索帮助

344bd9b3 5694891 D2dac590 5694891