versionorder

package
v0.170.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package versionorder orders the versions of one package by the rules of the ecosystem it comes from.

Every ecosystem orders differently. Debian's `3.0.17-1~deb12u3` is newer than `3.0.17-1~deb12u2` and `1.0~rc1` is older than `1.0`; PEP 440 puts `1.0rc1` before `1.0` and `1.0.post1` after it; Maven's `2.13.4.2` follows `2.13.4`. A comparison that reads dotted numbers alone gets each of these wrong, and a wrong order recommends an upgrade that leaves findings behind or a downgrade of a working dependency.

The rules are osv-scalibr's, which are the ones OSV's own matching uses. Where the ecosystem is not one it orders, or a version does not parse in it, Compare says so rather than guessing, and the caller keeps every version it was given.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(ecosystem, a, b string) (order int, ok bool)

Compare returns -1, 0 or +1 as a is older than, the same as or newer than b under ecosystem's rules. ok is false when the ecosystem is not one this orders, or either version does not parse in it, and then the order is unknown rather than equal.

func Ecosystem

func Ecosystem(purl, reported string) string

Ecosystem names the rules that order a package's versions, from its package URL or, without one, from the ecosystem a scanner reported. Empty when neither names rules this package knows.

Types

type Version added in v0.165.3

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

Version is one version parsed under one ecosystem's rules, for a caller comparing it many times. Comparing two Versions gives the answer Compare gives for the strings they were parsed from.

func Parse added in v0.165.3

func Parse(ecosystem, s string) (v Version, ok bool)

Parse reads s as a version under ecosystem's rules. ok is false where Compare would have no order for s against any version: the ecosystem is not one this orders, or s does not parse in it.

func (Version) Compare added in v0.165.3

func (v Version) Compare(w Version) (order int, ok bool)

Compare returns -1, 0 or +1 as v is older than, the same as or newer than w. Both come from Parse under one ecosystem; ok is false for a Version Parse did not return, or where the ecosystem's rules give the two no order.

Jump to

Keyboard shortcuts

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