version

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package version provides functionality for managing and retrieving version information of the application. Data is populated during the build process or as outlined during dev

Default Version: v0.0.0-dev.unknown is returned in the event Version is invalid

Default CommitHash, BuildDate, GoVersion: unknown is the default value applied in the absence of a built binary

Index

Constants

This section is empty.

Variables

View Source
var (
	Version    = "dev"     // e.g. "v0.1.0" or "v0.0.0-dev.abc1234"
	CommitHash = "unknown" // e.g. "abc1234"
	BuildDate  = "unknown" // e.g. "2025-07-15T10:30:00Z"
	GoVersion  = "unknown" // e.g. "go1.24.1"
)

Build information - set by ldflags during compilation

Functions

func GetVersion

func GetVersion() string

GetVersion returns just the version string

func IsValidSemVer

func IsValidSemVer(version string) bool

IsValidSemVer checks if the given version string follows semantic versioning format

Types

type BuildInfo

type BuildInfo struct {
	Version    string `json:"version"`
	CommitHash string `json:"commit_hash"`
	BuildDate  string `json:"build_date"`
	GoVersion  string `json:"go_version"`
	Platform   string `json:"platform"`
	ModuleInfo string `json:"module_info,omitempty"`
}

BuildInfo contains version and build information

func GetBuildInfo

func GetBuildInfo() *BuildInfo

GetBuildInfo returns complete build information

func (*BuildInfo) GetShortCommit

func (bi *BuildInfo) GetShortCommit() string

GetShortCommit returns the first 7 characters of the commit hash

func (*BuildInfo) IsDevelopment

func (bi *BuildInfo) IsDevelopment() bool

IsDevelopment returns true if this is a development build

func (*BuildInfo) String

func (bi *BuildInfo) String() string

String returns a human-readable version string

Jump to

Keyboard shortcuts

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