ota

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LastVersionURL = `https://api.github.com/repos/%s/releases/latest`
)

Variables

This section is empty.

Functions

func GetLastVersion

func GetLastVersion(repoName string) (string, string, error)

GetLastVersion 从 GitHub API 获取最新版本信息 repoName: GitHub 仓库名,如 "gowvp/owl" 返回 tag_name, body(release notes), error

Types

type OTA

type OTA struct {
	// contains filtered or unexported fields
}

OTA 提供版本检查和下载功能的结构体 OTA 只负责下载,不关心后续的解压、备份、替换等操作

func NewOTA

func NewOTA(repoName, filename string) *OTA

NewOTA 创建 OTA 实例 repoName: GitHub 仓库名,如 "gowvp/owl",也支持 "github.com/gowvp/owl" 格式 filename: 下载的文件名

func (*OTA) Download

func (o *OTA) Download() *OTA

Download 下载升级包到指定路径

func (*OTA) Error

func (o *OTA) Error() error

Error 返回错误

func (*OTA) GetLastVersion

func (o *OTA) GetLastVersion() (string, string, error)

GetLastVersion 从 GitHub API 获取最新版本信息 返回 tag_name, body(release notes), error

func (*OTA) SetProgressCallback

func (o *OTA) SetProgressCallback(callback func(current, total int64)) *OTA

SetProgressCallback 设置下载进度回调

type ProgressReader

type ProgressReader struct {
	Total   int64
	Current atomic.Int64
	io.Reader
	OnProgress func(current, total int64)
	// contains filtered or unexported fields
}

func NewProgressReader

func NewProgressReader(total int64, reader io.Reader, onProgress func(current, total int64)) *ProgressReader

func (*ProgressReader) Close

func (p *ProgressReader) Close()

func (*ProgressReader) Read

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

func (*ProgressReader) Start

func (p *ProgressReader) Start()

type ReleaseInfo

type ReleaseInfo struct {
	TagName string `json:"tag_name"`
	Body    string `json:"body"`
}

ReleaseInfo GitHub Release 信息

Jump to

Keyboard shortcuts

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