MCPcopy Index your code
hub / github.com/TruthHun/BookStack / CheckUpdate

Function CheckUpdate

commands/update.go:15–48  ·  view source on GitHub ↗

检查最新版本.

()

Source from the content-addressed store, hash-verified

13
14//检查最新版本.
15func CheckUpdate() {
16
17 resp, err := http.Get("https://api.github.com/repos/TruthHun/BookStack/tags")
18
19 if err != nil {
20 beego.Error("CheckUpdate => ", err)
21 os.Exit(1)
22 }
23
24 defer resp.Body.Close()
25 body, err := ioutil.ReadAll(resp.Body)
26 if err != nil {
27 beego.Error("CheckUpdate => ", err)
28 os.Exit(1)
29 }
30
31 var result []*struct {
32 Name string `json:"name"`
33 }
34
35 err = json.Unmarshal(body, &result)
36 fmt.Println("MinDoc current version => ", conf.VERSION)
37 if err != nil {
38 beego.Error("CheckUpdate => ", err)
39 os.Exit(0)
40 }
41
42 if len(result) > 0 {
43 fmt.Println("MinDoc last version => ", result[0].Name)
44 }
45
46 os.Exit(0)
47
48}

Callers 1

RegisterCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected