Skip to content
WoozyMastaPublic

About

Fast, dependency-free Go library for parsing, validating, rendering, and comparing Calendar Versioning (CalVer) values with explicit formats

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

calver

calver is a dependency-free Go library for parsing, rendering, and comparing Calendar Versioning values with explicit user-defined formats.

It supports Go 1.18 and later.

Status

The public API is intentionally format-aware: CalVer does not define a single grammar, modifier precedence, or universal ordering between week-based and month/day-based versions.

Installation

go get github.com/woozymasta/calver

Usage

Compile a layout once, then use it for parsing hot paths:

format, err := calver.Compile("release-<YYYY>.<0M>.<0D>-<MODIFIER>")
if err != nil {
  return err
}

version, ok := format.Parse("release-2026.07.24-rc.1")
if !ok {
  return errors.New("invalid version")
}

fmt.Println(version.Major())                   // 2026, true
fmt.Println(version.Series(calver.LevelMicro)) // release-2026.07.24

Construct values without accepting an external version string:

format := calver.MustCompile("<MAJOR>.<MINOR>.<MICRO>")
version, err := format.New(calver.Parts{Major: 1, Minor: 2, Micro: 3})
if err != nil {
  return err
}

next, err := version.BumpMinor() // 1.3.3; lower components are unchanged
if err != nil {
  return err
}

BumpMajor, BumpMinor, and BumpMicro only operate on their respective generic tokens. Calendar tokens are rejected to prevent accidental date arithmetic. HasLevel and Kind expose a format's component profile when calling code needs to distinguish generic versions from calendar values.

Supported tokens:

  • <YYYY>, <YY>, <0Y>, <MAJOR>
  • <MM>, <0M>, <MINOR>
  • <WW>, <0W>, <DD>, <0D>, <MICRO>
  • terminal <MODIFIER>

Literal < and > are escaped as << and >>. One token is allowed per logical level. Week formats cannot be combined with month or day tokens.

Comparison

Compare provides a deterministic structural order suitable for sorting. It compares numeric components numerically, opaque modifiers bytewise, then uses the rendered value as a stable tie-breaker.

Use CompatibleWith and CompareCalendar when calendar meaning matters. For example, 2026-07-24 and 2026.07.25 are compatible, while 2026-07-24 and 2026-W30 are not.

Modifier values intentionally have no SemVer semantics: there is no implicit "release is greater than prerelease" rule and rc.10 sorts before rc.2 under the default bytewise policy. Greater, GreaterOrEqual, Less, and LessOrEqual are convenience helpers with the same ordering semantics.

Performance

Format.Parse and Version.Compare are allocation-free for valid values. String returns the parsed input; use AppendTo when appending into a caller buffer.

Related projects

For Semantic Versioning, use the companion WoozyMasta/semver library.

About

Fast, dependency-free Go library for parsing, validating, rendering, and comparing Calendar Versioning (CalVer) values with explicit formats

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages