Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

semver source realm

Package semver is an on-chain port of the core of golang.org/x/mod/semver (and the spirit of github.com/Masterminds/s...

Overview

Package semver is an on-chain port of the core of golang.org/x/mod/semver (and the spirit of github.com/Masterminds/semver): parse "vMAJOR.MINOR.PATCH [-prerelease][+build]" strings and compare them with correct Semantic Versioning 2.0.0 precedence. Pure and deterministic — no time, randomness, goroutines, or I/O.

Functions 4

func Compare

Action
1func Compare(a, b string) int
source

Compare returns -1, 0, or +1 as a < b, a == b, or a > b under semver precedence. Unparseable inputs sort after everything valid (and equal to each other), so Compare never panics.

func Submit

crossing Action
1func Submit(cur realm, version string)
source

Submit stores a valid version on-chain, tagged with the caller's address, so Render("/sorted") can list everyone's submissions in precedence order.

func Parse

Action
1func Parse(s string) (Version, error)
source

Parse reads "vMAJOR.MINOR.PATCH[-prerelease][+build]". The leading 'v' is optional. Numeric fields must be non-empty digit runs without leading zeros.

Types 1

type Version

struct
1type Version struct {
2	Major, Minor, Patch int
3	Pre                 []string // pre-release identifiers (dot-separated)
4	Build               string   // build metadata (after '+')
5	Orig                string   // original input
6}
source

Version is a parsed semantic version. Build metadata is retained for display but, per the spec, is ignored when comparing precedence.

Methods on Version

func Canonical

method on Version
1func (v Version) Canonical() string
source

Canonical renders the parsed version back to a canonical string.

Imports 6

Source Files 2