version

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 5 Imported by: 0

README

version

Build-time and runtime version information for the ling-base library.

Variables

Variable Default Description
Version "1.0.0" Semantic version string
GitCommit "unknown" Short Git commit hash
BuildTime "unknown" Build timestamp (RFC3339)
GoVersion "unknown" Go toolchain version

Functions

  • GetVersion() — returns the version string
  • GetVersionInfo() — returns a human-readable summary
  • GetGitCommit() — returns the Git commit hash
  • GetBuildTime() — returns the build timestamp
  • GetGoVersion() — returns the Go version

Override at build time with -ldflags:

go build -ldflags "\
  -X github.com/LingByte/ling-base/version.Version=1.2.0 \
  -X github.com/LingByte/ling-base/version.GitCommit=$(git rev-parse --short HEAD) \
  -X github.com/LingByte/ling-base/version.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
  -X github.com/LingByte/ling-base/version.GoVersion=$(go version)" \
  ./...

Automatic resolution

When not overridden via -ldflags, GitCommit and BuildTime are resolved automatically from:

  1. VCS build info (Go 1.18+ debug.ReadBuildInfo)
  2. The local git repository (via git command)

Usage

import "github.com/LingByte/ling-base/version"

fmt.Println(version.GetVersionInfo())
// Output: 1.0.0 (commit: abc123def456, built at: 2026-01-15T10:30:00Z, go: go1.26.2)

License

MIT

Documentation

Overview

Package version provides build-time and runtime version information.

The default values can be overridden at link time with -ldflags:

-ldflags "-X github.com/LingByte/ling-base/version.Version=1.0.0"

When not overridden, GitCommit and BuildTime are resolved automatically from VCS build info (Go 1.18+) or the local git repository.

Index

Constants

This section is empty.

Variables

View Source
var BuildTime = "unknown"

BuildTime is the build timestamp (RFC3339).

View Source
var GitCommit = "unknown"

GitCommit is the short Git commit hash.

View Source
var GoVersion = "unknown"

GoVersion is the Go toolchain version used to build.

View Source
var Version = "1.0.0"

Version is the semantic version string.

Functions

func GetBuildTime

func GetBuildTime() string

GetBuildTime returns the build timestamp.

func GetGitCommit

func GetGitCommit() string

GetGitCommit returns the Git commit hash.

func GetGoVersion

func GetGoVersion() string

GetGoVersion returns the Go version.

func GetVersion

func GetVersion() string

GetVersion returns the version string.

func GetVersionInfo

func GetVersionInfo() string

GetVersionInfo returns a human-readable version summary.

Types

This section is empty.

Jump to

Keyboard shortcuts

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