use os.Executable() and .LTE() for safety in example
This commit is contained in:
parent
6329a43531
commit
db4f96105a
12
README.md
12
README.md
|
@ -144,7 +144,7 @@ func confirmAndSelfUpdate() {
|
|||
}
|
||||
|
||||
v := semver.MustParse(version)
|
||||
if !found || latest.Version.Equals(v) {
|
||||
if !found || latest.Version.LTE(v) {
|
||||
log.Println("Current version is the latest")
|
||||
return
|
||||
}
|
||||
|
@ -159,7 +159,12 @@ func confirmAndSelfUpdate() {
|
|||
return
|
||||
}
|
||||
|
||||
if err := selfupdate.UpdateTo(latest.AssetURL, os.Args[0]); err != nil {
|
||||
exe, err := os.Executable()
|
||||
if err != nil {
|
||||
log.Println("Could not locate executable path")
|
||||
return
|
||||
}
|
||||
if err := selfupdate.UpdateTo(latest.AssetURL, exe); err != nil {
|
||||
log.Println("Error occurred while updating binary:", err)
|
||||
return
|
||||
}
|
||||
|
@ -171,6 +176,9 @@ If GitHub API token is set to `[token]` section in `gitconfig` or `$GITHUB_TOKEN
|
|||
this library will use it to call GitHub REST API. It's useful when reaching rate limits or when using
|
||||
this library with private repositories.
|
||||
|
||||
Note that `os.Args[0]` is not available since it does not provide a full path to executable. Instead,
|
||||
please use `os.Executable()`.
|
||||
|
||||
Please see [the documentation page][GoDoc] for more detail.
|
||||
|
||||
This library should work with [GitHub Enterprise][]. To configure API base URL, please setup `Updater`
|
||||
|
|
Loading…
Reference in New Issue