mirror of
https://github.com/MedzikUser/go-github-selfupdate.git
synced 2024-08-15 03:25:29 +00:00
Merge pull request #4 from Songmu/os-executable
use os.Executable instead of using os.Args[0]
This commit is contained in:
commit
00163d5092
1 changed files with 8 additions and 3 deletions
|
@ -2,13 +2,14 @@ package selfupdate
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/blang/semver"
|
|
||||||
"github.com/inconshreveable/go-update"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/blang/semver"
|
||||||
|
"github.com/inconshreveable/go-update"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UpdateTo download an executable from assetURL and replace the current binary with the downloaded one. cmdPath is a file path to command executable.
|
// UpdateTo download an executable from assetURL and replace the current binary with the downloaded one. cmdPath is a file path to command executable.
|
||||||
|
@ -65,5 +66,9 @@ func UpdateCommand(cmdPath string, current semver.Version, slug string) (*Releas
|
||||||
// UpdateSelf updates the running executable itself to the latest version.
|
// UpdateSelf updates the running executable itself to the latest version.
|
||||||
// 'slug' represents 'owner/name' repository on GitHub and 'current' means the current version.
|
// 'slug' represents 'owner/name' repository on GitHub and 'current' means the current version.
|
||||||
func UpdateSelf(current semver.Version, slug string) (*Release, error) {
|
func UpdateSelf(current semver.Version, slug string) (*Release, error) {
|
||||||
return UpdateCommand(os.Args[0], current, slug)
|
cmdPath, err := os.Executable()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return UpdateCommand(cmdPath, current, slug)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue