updater

package
v1.5.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SHA256SUMS = "SHA256SUMS"
)

Variables

This section is empty.

Functions

func DownloadFile

func DownloadFile(ctx context.Context, url, filepath string, hash string) error

DownloadFile 以 "已下载 XMB/YMB (Z%)" 格式显示进度

func Update

func Update(opt UpdateOption) error

Types

type FetchError

type FetchError struct {
	StatusCode int
	Status     string
}

func (*FetchError) Error

func (e *FetchError) Error() string

type ProgressReader

type ProgressReader struct {
	Reader io.Reader
	Total  int64
	Loaded int64
	Start  time.Time
}

ProgressReader 计算下载进度

func (*ProgressReader) Read

func (p *ProgressReader) Read(buf []byte) (int, error)

Read 实现 io.Reader 接口

type ReleaseInfo

type ReleaseInfo struct {
	TagName string `json:"tag_name"`
	Body    string `json:"body"`
	Assets  []struct {
		Name               string `json:"name"`
		BrowserDownloadURL string `json:"browser_download_url"`
		Size               int    `json:"size"`
	} `json:"assets"`
}

type UpdateAsset

type UpdateAsset struct {
	URL       string
	OriginURL string
	Name      string
	SHA256    string
	Size      int
}

func FindUpdateAsset

func FindUpdateAsset(info UpdateInfo) *UpdateAsset

type UpdateInfo

type UpdateInfo struct {
	Tag    string
	Body   string
	Note   string
	Assets []UpdateAsset
}

func CheckForUpdate

func CheckForUpdate(duration time.Duration) (*UpdateInfo, error)

type UpdateOption

type UpdateOption struct {
	Yes     bool
	Retry   int
	Timeout time.Duration
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL