versioncheck

package
v0.0.0-...-d931726 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package versioncheck provides endpoints to retrieve version information via different providers and utilities to compare versions.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMatch = errors.New("no match")
)
View Source
var (
	ErrNoTags = errors.New("no tags available")
)

Functions

This section is empty.

Types

type CompareType

type CompareType int

CompareType specifies the type of comparison used for different semantic versions.

const (
	Major CompareType = iota
	Minor
	Patch
	Exact
)

type GitHubProvider

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

GitHubProvider implements Provider using a GitHub repositories tag list as source for the current version.

func NewGitHubProvider

func NewGitHubProvider(owner, repo string) *GitHubProvider

NewGitHubProvider returns a new instance of GitHubProvider with the passed repository owner and name as source.

func (*GitHubProvider) GetLatestVersion

func (gh *GitHubProvider) GetLatestVersion() (v Semver, err error)

type Provider

type Provider interface {
	GetLatestVersion() (v Semver, err error)
}

Provider implements a getter for version information from a specified source.

type Semver

type Semver struct {
	Major      int    `json:"major"`
	Minor      int    `json:"minor"`
	Patch      int    `json:"patch"`
	Attachment string `json:"attachment"`
}

Semver represents the elements of a semantic version. See: https://semver.org/spec/v2.0.0.html

func ParseSemver

func ParseSemver(raw string) (v Semver, err error)

ParseSemver takes a semantic version as string and tries to parse it into a Semver instance.

func (Semver) Equal

func (v Semver) Equal(v2 Semver, et ...CompareType) (ok bool)

Equal returns true if the given semver equals the current semver down to the given compare type.

func (Semver) LaterThan

func (v Semver) LaterThan(v2 Semver, et ...CompareType) (ok bool)

LaterThan returns true if the given semver is later than the current semver down to the given compare type.

func (Semver) OlderThan

func (v Semver) OlderThan(v2 Semver, et ...CompareType) (ok bool)

OlderThan returns true if the given semver is older than the current semver down to the given compare type.

func (Semver) String

func (v Semver) String() (r string)

String returns the string representation of the current Semver.

Jump to

Keyboard shortcuts

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