From 6f79035c5c06a9baed653a7574c34e0d4088d8e0 Mon Sep 17 00:00:00 2001
From: zanbin168 <zanbin168@qq.com>
Date: 星期二, 16 五月 2023 23:19:37 +0800
Subject: [PATCH] update

---
 update.go |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/update.go b/update.go
index 924ec7e..a765f13 100644
--- a/update.go
+++ b/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)
 }
 

--
Gitblit v1.8.0