anno

package module
v0.0.0-...-74faffe Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: BSD-3-Clause Imports: 6 Imported by: 2

Documentation

Overview

anno is a versioning scheme based on day of year and elapsed seconds in UTC.

Structure:

Separater is a simple dot "." by default.
  Size: 2x1 [Can be adjusted by anno.Separator (global) or per object UseSeparater(string).]
Years (00-99)
  Size: 2 [Your software will most probably outlast the century.]
Day of year (000-365/366)
  Size: 3 [zero padded]
Seconds elapsed on that day (00000-86400)
  Size: 5 [zero padded]

Apply extensions at discretion. Can contain modifier, major, minor, micro tags or whatever you wish for. You can make anno a unique value eg. (session-id) by adding a random value through extensions. (see examples below)

YY.DOY.SECONDS → 25.171.61040

YY  = Current year minus 2000. This is not going to outlast to the next century.
DOY = Number of day for the current year.
SEC = Elapsed seconds of the current day. Unique enough for most use-cases. Can be unique by adding a random value through extensions.

Features:

  • Contains useful information like a date unlike semver's arbitrary values.
  • Not day specific like calver, but second of day specific.
  • Unique enough for most version use-cases.
  • It is a text sortable alternative to semver¹ or calver².
  • Layout is flexible and extensible. (separator/extension/connector)
  • Collects basic additional information for git repositories on request if available. (UNIX-only? Not tested on windows yet.)

Examples:

25.171.61454+main·4e38b9c·foo·bar
  Contains git values (branch/commit) and foo, bar extensions.

anno -a foo -a bar -a $(printf "%04x:%04x" $RANDOM $RANDOM)
25.171.62238+main·4e38b9c·foo·bar·1cf4:663b
  Command line example with extensions foo, bar and random hex.

¹ https://semver.org ² https://calver.org

Index

Constants

This section is empty.

Variables

View Source
var (
	Separator string = "."
	Extension string = "·"
	Connector string = "+"
)
View Source
var (
	// Nil represents 2000-01-01 00:00:00.000 UTC
	Nil = &Anno{date: time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC), separator: Separator, extension: Extension, connector: Connector}
)

Functions

func Micro

func Micro() string

Micro returns an anno.Now() string with microseconds appended.

Types

type Anno

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

Anno contains all values.

func New

func New(date time.Time, git bool, extensions ...string) (*Anno, error)

New creates an Anno from time and looks for git information if setting is true.

func Now

func Now() *Anno

Now returns the Anno tag without extensions.

func Parse

func Parse(input string) (*Anno, error)

Parse validates the input and returns an Anno.

func (*Anno) Anno

func (a *Anno) Anno() string

Anno returns only the Anno without extensions or git even if available.

func (*Anno) Extensions

func (a *Anno) Extensions() []string

Extensions returns all values of the given Anno.

func (*Anno) Git

func (a *Anno) Git() (string, string)

Git returns the git (branch/commit) values of the given Anno.

func (*Anno) Integer

func (a *Anno) Integer() uint64

Integer converts the Anno value to uint64.

func (*Anno) String

func (a *Anno) String() string

String implements the Stinger interface for the Anno type.

func (*Anno) Time

func (a *Anno) Time() time.Time

Time returns the time.Time of the given Anno.

func (*Anno) UseConnector

func (a *Anno) UseConnector(connector string) *Anno

func (*Anno) UseExtension

func (a *Anno) UseExtension(extension string) *Anno

func (*Anno) UseSeparator

func (a *Anno) UseSeparator(separator string) *Anno

type Annos

type Annos []*Anno

Annos is a collection of Anno that implements the sort interface.

func (Annos) Len

func (a Annos) Len() int

func (Annos) Less

func (a Annos) Less(i, j int) bool

func (Annos) Swap

func (a Annos) Swap(i, j int)

Directories

Path Synopsis
cmd
anno Module

Jump to

Keyboard shortcuts

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