version

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package version exposes the huan version string, embedded from the VERSION file at build time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func String

func String() string

String returns the huan version (e.g. "0.1.0").

func StringWithVCS

func StringWithVCS() string

StringWithVCS returns the version suffixed with short SHA (and -dirty marker) when VCS info is available. Falls back to plain version when not. Format examples:

"0.1.0"                       (no VCS info)
"0.1.0 (87b2836)"             (clean commit)
"0.1.0 (87b2836-dirty)"       (uncommitted changes at build time)

Types

type VCSInfo

type VCSInfo struct {
	SHA        string // short SHA (first 7 chars), empty if unavailable
	Dirty      bool   // true if working tree had uncommitted changes
	CommitTime string // ISO 8601 / RFC 3339 of the commit, empty if unavailable
	Available  bool   // false when no VCS info was embedded at all
}

VCSInfo carries VCS (git) provenance extracted from debug.ReadBuildInfo. All fields are zero-valued if the binary was built outside a git working tree (e.g. via `go install` from a tarball) or with -buildvcs=false.

func VCS

func VCS() VCSInfo

VCS returns VCS provenance from Go's embedded build info (Go 1.18+ auto- embeds VCS settings when building from a git working tree; no -ldflags injection needed). When the binary was not built from a git checkout, Available is false and all other fields are zero.

The SHA is shortened to 7 chars to match `git log --oneline` style; this is enough for "which commit produced this binary" identification while keeping `huan version` output compact.

Jump to

Keyboard shortcuts

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