MCPcopy Index your code
hub / github.com/voidint/g / selfUpdate

Function selfUpdate

cli/self_update.go:38–58  ·  view source on GitHub ↗
(*cli.Context)

Source from the content-addressed store, hash-verified

36)
37
38func selfUpdate(*cli.Context) (err error) {
39 up := github.NewReleaseUpdater()
40
41 // 检查更新
42 latest, yes, err := up.CheckForUpdates(semver.MustParse(build.ShortVersion), "voidint", "g")
43 if err != nil {
44 return cli.Exit(errstring(err), 1)
45 }
46 if !yes {
47 fmt.Printf("You are up to date! g v%s is the latest version.\n", build.ShortVersion)
48 return nil
49 }
50 fmt.Printf("A new version of g(%s) is available\n", latest.TagName)
51
52 // 应用更新
53 if err = up.Apply(latest, findAsset, findChecksum); err != nil {
54 return cli.Exit(errstring(err), 1)
55 }
56 fmt.Println("Update completed")
57 return nil
58}
59
60func findAsset(items []github.Asset) (idx int) {
61 ext := "tar.gz"

Callers

nothing calls this directly

Calls 4

CheckForUpdatesMethod · 0.95
ApplyMethod · 0.95
NewReleaseUpdaterFunction · 0.92
errstringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…