identifier

package
v0.0.0-...-e84a8d2 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrProgramNotSupported = errors.New("program not supported")
)

Functions

func CompareSemverVersions

func CompareSemverVersions(a, b SemverVersion) int

func GetProgramName

func GetProgramName(p Program) string

GetProgramName returns the name of the given Program.

func Satisfies

func Satisfies(version string, requirement string) bool

Satisfies returns true if the version matches the semver. version is the version of the program, and requirement is a semver requirement. The semver requirement is a string that follows the conventions in https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html.

Examples (version is on the left, requirement is on the right): - 1.2.3 matches 1.2.3 - 1.2.3 matches ^1.2.3 - 1.2.3 does not match 1.2 - 1.2.3 matches ~1.2.3 - 1.2.3 matches ~1.2 - 1.2.3 matches ~1 - 1.2.3 does not match ~2

Types

type Program

type Program int

enum for Programs that we can identify

const (
	Make Program = iota
	Git
	Bash
	Go
	Protobuf
	PkgConfig
	Poetry
)

func GetProgram

func GetProgram(programName string) (*Program, error)

GetProgram returns the Program for the given name, if found.

type Requirement

type Requirement struct {
	Type       RequirementType
	Version    SemverVersion
	MaxVersion *SemverVersion
}

func NewRequirement

func NewRequirement(s string) (*Requirement, error)

type RequirementType

type RequirementType int
const (
	Exact RequirementType = iota
	Caret
	Tilde
	SingleConditionEqual
	SingleConditionGreaterThan
	SingleConditionLessThan
	SingleConditionGreaterThanOrEqual
	SingleConditionLessThanOrEqual
)

type SemverVersion

type SemverVersion struct {
	Major int
	Minor *int
	Patch *int
}

func ParseVersion

func ParseVersion(s string) (*SemverVersion, error)

type Version

type Version string

SemverVersion is a string, should be lexicographically sortable (e.g. semver).

func Identify

func Identify(p Program, zlog *zerolog.Logger) (Version, error)

Identify returns the version of the program p, or an error if the program is not supported.

Jump to

Keyboard shortcuts

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