golang的私有化定制自动更新插件
zanbin168
2023-05-16 6f79035c5c06a9baed653a7574c34e0d4088d8e0
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)
}