|
|
@ -1,4 +1,4 @@
|
|
|
|
// Copyright © 2023 OpenIM. All rights reserved.
|
|
|
|
// Copyright ? 2023 OpenIM. All rights reserved.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
@ -99,22 +99,23 @@ func main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// getLatestVersion fetches the latest version number from a given URL.
|
|
|
|
// getLatestVersion fetches the latest version number from a given URL.
|
|
|
|
func getLatestVersion(url string) (string, error) {
|
|
|
|
// 未使用函数
|
|
|
|
resp, err := http.Get(url)
|
|
|
|
// func getLatestVersion(url string) (string, error) {
|
|
|
|
if err != nil {
|
|
|
|
// resp, err := http.Get(url)
|
|
|
|
return "", err
|
|
|
|
// if err != nil {
|
|
|
|
}
|
|
|
|
// return "", err
|
|
|
|
defer resp.Body.Close()
|
|
|
|
// }
|
|
|
|
|
|
|
|
// defer resp.Body.Close()
|
|
|
|
|
|
|
|
|
|
|
|
location := resp.Header.Get("Location")
|
|
|
|
// location := resp.Header.Get("Location")
|
|
|
|
if location == "" {
|
|
|
|
// if location == "" {
|
|
|
|
return defaultTemplateVersion, nil
|
|
|
|
// return defaultTemplateVersion, nil
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// Extract the version number from the URL
|
|
|
|
// // Extract the version number from the URL
|
|
|
|
latestVersion := filepath.Base(location)
|
|
|
|
// latestVersion := filepath.Base(location)
|
|
|
|
return latestVersion, nil
|
|
|
|
// return latestVersion, nil
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// downloadAndExtract downloads a file from a URL and extracts it to a destination directory.
|
|
|
|
// downloadAndExtract downloads a file from a URL and extracts it to a destination directory.
|
|
|
|
func downloadAndExtract(url, destDir string) error {
|
|
|
|
func downloadAndExtract(url, destDir string) error {
|
|
|
@ -164,3 +165,4 @@ func startProcess(cmdPath string) {
|
|
|
|
fmt.Printf("Failed to start process %s: %v\n", cmdPath, err)
|
|
|
|
fmt.Printf("Failed to start process %s: %v\n", cmdPath, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|