gover

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: AGPL-3.0 Imports: 8 Imported by: 1

README

GoVer

Golang version checker - the simple way to check version. GoVer can check the latest version from GitHub releases by tags with MAJOR.MINOR.MIRCRO pattern.

Install

go get github.com/black40x/gover

Usage

You can check version from the latest GitHub release (via tag_name).

func CheckVersion() {
    currentV, _ := NewVersion("v0.0.30")
    latestV, err := GetGithubVersion("black40x", "tunl-cli")
    if err == nil {
        ver, _ := latestV.GetVersion()
        fmt.Printf("Current version: %s \n", currentV.String())
        fmt.Printf("Latest version: %s \n", ver.String())
    
        if ver.NewerThan(*currentV) {
            fmt.Println("Update available")
            fmt.Printf("Update information: \n%s\n", latestV.Body)
        }
    }
}

Documentation

Index

Constants

View Source
const VersionChars = "1234567890."

Variables

View Source
var InvalidVersion = errors.New("invalid version string")

Functions

This section is empty.

Types

type GitHubVersion

type GitHubVersion struct {
	Name        string `json:"name"`
	TagName     string `json:"tag_name"`
	Body        string `json:"body"`
	HtmlUrl     string `json:"html_url"`
	CreatedAt   string `json:"created_at"`
	PublishedAt string `json:"published_at"`
}

func GetGithubVersion

func GetGithubVersion(user, repo string) (*GitHubVersion, error)

func (GitHubVersion) GetVersion

func (v GitHubVersion) GetVersion() (*Version, error)

type Version

type Version struct {
	Major int
	Minor int
	Micro int
	// contains filtered or unexported fields
}

func NewVersion

func NewVersion(vStr string) (*Version, error)

func (Version) EqualOrHigher

func (v Version) EqualOrHigher(ver Version) bool

func (Version) EqualOrHigherStr

func (v Version) EqualOrHigherStr(ver string) bool

func (Version) NewerThan

func (v Version) NewerThan(ver Version) bool

func (Version) NewerThanStr

func (v Version) NewerThanStr(ver string) bool

func (Version) String

func (v Version) String() string

func (Version) UpTo

func (v Version) UpTo(ver Version) bool

func (Version) UpToStr

func (v Version) UpToStr(ver string) bool

Jump to

Keyboard shortcuts

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