golang的私有化定制自动更新插件
zanbin168
2023-05-16 6f79035c5c06a9baed653a7574c34e0d4088d8e0
update
1个文件已修改
10 ■■■■■ 已修改文件
update.go 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
update.go
@@ -8,6 +8,7 @@
    "io/ioutil"
    "net/http"
    "os"
    "os/exec"
    "path/filepath"
    "runtime"
    "strconv"
@@ -103,17 +104,12 @@
// Install binary to replace the current version.
func (m *Manager) Install(path string) error {
    executablePath, err := os.Executable()
    if err != nil {
        return errors.Wrapf(err, "looking up path of %q", m.Command)
    }
    absolutePath, err := filepath.Abs(executablePath)
    bin, err := exec.LookPath("./" + m.Command)
    if err != nil {
        return errors.Wrapf(err, "looking up path of %q", m.Command)
    }
    dir := strings.TrimSuffix(absolutePath, "/"+m.Command)
    dir := filepath.Dir(bin)
    return m.InstallTo(path, dir)
}