mirror of
https://github.com/CyberL1/holesail-proxy.git
synced 2025-06-28 08:09:42 -04:00
feat: upgrade command
This commit is contained in:
6
utils/constants.go
Normal file
6
utils/constants.go
Normal file
@ -0,0 +1,6 @@
|
||||
package utils
|
||||
|
||||
var (
|
||||
Version string
|
||||
GithubReleaseUrl = "https://api.github.com/repos/CyberL1/holesail-proxy/releases/latest"
|
||||
)
|
12
utils/types.go
Normal file
12
utils/types.go
Normal file
@ -0,0 +1,12 @@
|
||||
package utils
|
||||
|
||||
type GithubRelease struct {
|
||||
TagName string `json:"tag_name"`
|
||||
Prerelease bool
|
||||
}
|
||||
|
||||
type GithubFile struct {
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
DownloadUrl string `json:"download_url"`
|
||||
}
|
24
utils/version.go
Normal file
24
utils/version.go
Normal file
@ -0,0 +1,24 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetLatestCliVersion() (*GithubRelease, error) {
|
||||
resp, err := http.Get(GithubReleaseUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
release := &GithubRelease{}
|
||||
err = json.Unmarshal(body, release)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return release, nil
|
||||
}
|
Reference in New Issue
Block a user