gvgo

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: BSD-3-Clause Imports: 3 Imported by: 2

README

gvgo

Go Reference

A library to used to parse go info.

Docs in pkg.go.dev.

Documentation

Overview

Package gvgo used to parse version info.

Index

Constants

View Source
const (
	KindAlpha = "alpha"
	KindBeta  = "beta"
	KindRC    = "rc"
)

Variables

View Source
var (
	ErrMissMain error = versionError{"main part is empty"}
	ErrMainLong error = versionError{"main part is too long"}
)

Functions

func Compare

func Compare(a, b string) int

Compare compares two string. It not care about if they are valid.

func CompareVersion

func CompareVersion(a, b Version) int

CompareVersion compares two Version.

func IsValid

func IsValid(v string) bool

IsValid checks if a string is a valid Version.

func IsValidKind added in v0.2.0

func IsValidKind(kind string) bool

IsValidKind returns true if kind is one of kinds("alpha", "beta" and "rc").

Types

type Version

type Version struct {
	Major string // decimal
	Minor string // decimal or ""
	Patch string // decimal or ""
	Kind  string // "", "alpha", "beta", "rc"
	Pre   string // decimal or ""
}

A Version is a parsed version: major[.Minor[.Patch]][-kind[(.)pre]] The numbers are the original decimal strings to avoid integer overflows and since there is very little actual math. (Probably overflow doesn't matter in practice, but at the time this code was written, there was an existing test that used 1.99999999999, which does not fit in an int on 32-bit platforms. The "big decimal" representation avoids the problem entirely.)

func Parse

func Parse(x string) (v Version, err error)

Parse parses the version string. Whether starts with "v" or not are both OK.

func (Version) Compare

func (v Version) Compare(y Version) int

func (Version) String

func (v Version) String() string

String print readable version. But it will not include "v" at first.

Jump to

Keyboard shortcuts

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