version

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: Apache-2.0, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultReleasesURL = "https://github.com/jiaozifs/jiaozifs/releases"

	GithubRepoOwner = "jiaozifs"
	GithubRepoName  = "jiaozifs"
)

Variables

View Source
var BuildVersion = "dev"

BuildVersion program version

View Source
var CurrentCommit string

CurrentCommit current program commit

View Source
var ErrHTTPStatus = errors.New("unexpected HTTP status code")

Functions

func IsVersionUnreleased

func IsVersionUnreleased() bool

func UserVersion

func UserVersion() string

UserVersion return build version and current commit

Types

type CachedVersionSource

type CachedVersionSource struct {
	Source Source
	// contains filtered or unexported fields
}

func NewCachedSource

func NewCachedSource(src Source, cachePeriod time.Duration) *CachedVersionSource

func (*CachedVersionSource) FetchLatestVersion

func (cs *CachedVersionSource) FetchLatestVersion() (string, error)

type Checker

type Checker struct {
	Client  http.Client
	Version string
	// contains filtered or unexported fields
}

func NewVersionChecker

func NewVersionChecker() *Checker

func (*Checker) CheckLatestVersion

func (a *Checker) CheckLatestVersion() (*LatestVersionResponse, error)

CheckLatestVersion will return the latest version of the current package compared to the current version

type GithubReleases

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

func NewGithubReleases

func NewGithubReleases(owner, repository string) *GithubReleases

func (*GithubReleases) FetchLatestVersion

func (gh *GithubReleases) FetchLatestVersion() (string, error)

type IChecker

type IChecker interface {
	CheckLatestVersion() (*LatestVersionResponse, error)
}

type LatestVersionResponse

type LatestVersionResponse struct {
	CheckTime      time.Time `json:"check_time"`
	Outdated       bool      `json:"outdated"`
	LatestVersion  string    `json:"latest_version"`
	CurrentVersion string    `json:"current_version"`
}

func CheckLatestVersion

func CheckLatestVersion(targetVersion string) (*LatestVersionResponse, error)

type RepositoryRelease

type RepositoryRelease struct {
	TagName    string `json:"tag_name,omitempty"`
	Name       string `json:"name,omitempty"`
	Draft      bool   `json:"draft,omitempty"`
	Prerelease bool   `json:"prerelease,omitempty"`
	ID         int64  `json:"id,omitempty"`
	URL        string `json:"url,omitempty"`
}

type Source

type Source interface {
	FetchLatestVersion() (string, error)
}

func NewDefaultVersionSource

func NewDefaultVersionSource(cachePeriod time.Duration) Source

Jump to

Keyboard shortcuts

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