Documentation
¶
Index ¶
- Constants
- func CompareVersions(v1, v2 string) int
- func DefaultCachePath() (string, error)
- func IsExpired(cache *CacheData, ttl time.Duration) bool
- func IsExpiredAt(cache *CacheData, ttl time.Duration, now time.Time) bool
- func LaunchBackgroundWorker(execPath, currentVersion string, opts CatalogOptions) error
- func ReadNotice(currentVersion string, now time.Time) string
- func RunLeasedWorker(ctx context.Context, currentVersion string, opts CatalogOptions, ...) error
- func RunWorker(ctx context.Context, currentVersion string, opts CatalogOptions, ...) error
- func SaveCache(path string, cache *CacheData) error
- func VersionFromTag(tag string) (string, bool)
- type CacheData
- type CatalogOptions
- type Release
- type ReleaseAsset
Constants ¶
View Source
const ( DefaultRepo = "CGuiho/mirror" DefaultBaseURL = "https://api.github.com" )
View Source
const CacheMaxAge = 24 * time.Hour
View Source
const (
WorkerEnvVar = "MIRROR_UPDATE_WORKER"
)
Variables ¶
This section is empty.
Functions ¶
func CompareVersions ¶
func DefaultCachePath ¶
DefaultCachePath returns ~/.guiho/mirror/cache.json.
func LaunchBackgroundWorker ¶
func LaunchBackgroundWorker(execPath, currentVersion string, opts CatalogOptions) error
func ReadNotice ¶
ReadNotice is foreground-safe: it performs local file IO only.
func RunLeasedWorker ¶
func VersionFromTag ¶
Types ¶
type CacheData ¶
type CacheData struct {
LatestVersion string `json:"latestVersion"`
CurrentVersion string `json:"currentVersion"`
LastCheck time.Time `json:"lastCheck"`
ReleaseURL string `json:"releaseUrl"`
UpdateAvailable bool `json:"updateAvailable"`
ReleaseNotes string `json:"releaseNotes,omitempty"`
}
CacheData is the validated, local-only result of the last update check.
type CatalogOptions ¶
type Release ¶
type Release struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
PublishedAt time.Time `json:"published_at"`
HTMLURL string `json:"html_url"`
Body string `json:"body"`
Prerelease bool `json:"prerelease"`
Draft bool `json:"draft"`
Assets []ReleaseAsset `json:"assets"`
Version string `json:"-"`
}
func FetchLatestRelease ¶
func FetchLatestRelease(ctx context.Context, opts CatalogOptions) (*Release, error)
func FetchReleases ¶
func FetchReleases(ctx context.Context, opts CatalogOptions) ([]Release, error)
FetchReleases exhausts the GitHub catalog, retains only canonical mirror/vX.Y.Z tags, deduplicates by tag, and sorts by semantic version.
type ReleaseAsset ¶
Click to show internal directories.
Click to hide internal directories.