Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatCalVer ¶
FormatCalVer formats a time using the given format string, with support for ISO week numbers. Supports special format codes: - "YYYY" or "2006" for 4-digit year - "WW" for ISO week number (01-53) All other format codes are passed to time.Format(). Examples: - "2006.01.02" -> "2025.10.03" (year.month.day) - "2006.WW" -> "2025.40" (year.week)
func StripPrefix ¶
StripPrefix removes a prefix (e.g., "v") from a version string.
func WithPrefix ¶
WithPrefix adds a prefix (e.g., "v") to a version string.
Types ¶
type Version ¶
type Version struct {
Scheme Scheme
Raw string
// SemVer fields
Major int
Minor int
Patch int
Pre string
Meta string
// CalVer fields
CalVerDate string // e.g., "2025.10.02"
CalVerSequence int // optional sequence number for same-day releases
}
Version represents a parsed version tag.
func NextCalVer ¶
NextCalVer generates the next calendar version using the given format and current time. If the current version is for the same period (e.g., same day/week), it increments the sequence number. Supports special format codes via FormatCalVer (e.g., "WW" for ISO week number).
For week-based formats (containing "WW"), build numbers start at 1 for clarity. For date-based formats, build numbers start at 0 (omitted) for the first release.
func ParseCalVer ¶
ParseCalVer parses a calendar version string (without prefix). Format: YYYY.MM.DD[.SEQUENCE][-PRERELEASE][+METADATA]
or: YYYY.WW[.SEQUENCE][-PRERELEASE][+METADATA]
Supports both date-based (3 parts: year.month.day) and week-based (2 parts: year.week) formats.
func ParseSemVer ¶
ParseSemVer parses a semantic version string (without prefix). Format: MAJOR.MINOR.PATCH[-PRERELEASE][+METADATA]
func (*Version) BumpSemVer ¶
BumpSemVer increments the version according to the bump type.
func (*Version) WithMetadata ¶
WithMetadata returns a new version with the build metadata set.
func (*Version) WithPrerelease ¶
WithPrerelease returns a new version with the prerelease identifier set.