version

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package version implements the "version" CLI command.

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is the application version string. When built from a tagged release or installed via "go install", the Go toolchain embeds the module version automatically, and it is read from build info at startup. Override at link time only if the auto-detected value is incorrect:

go build -ldflags "-X 'github.com/StevenACoffman/gorouter/cmd/version.Version=v1.2.3'"

Functions

This section is empty.

Types

type Config

type Config struct {
	*root.Config
	JSON    bool
	Flags   *ff.FlagSet
	Command *ff.Command
}

Config holds the configuration for the version command.

func New

func New(parent *root.Config) *Config

New creates and registers the version command with the given parent config.

type Info

type Info struct {
	GitVersion   string `json:"gitVersion"`
	ModuleSum    string `json:"moduleChecksum"`
	GitCommit    string `json:"gitCommit"`
	GitTreeState string `json:"gitTreeState"`
	BuildDate    string `json:"buildDate"`
	BuiltBy      string `json:"builtBy"`
	GoVersion    string `json:"goVersion"`
	Compiler     string `json:"compiler"`
	Platform     string `json:"platform"`

	ASCIIName   string `json:"-"`
	Name        string `json:"-"`
	Description string `json:"-"`
	URL         string `json:"-"`
}

Info holds build and VCS metadata for structured output.

func GetVersionInfoFrom

func GetVersionInfoFrom(bi *debug.BuildInfo, _ string, options ...Option) *Info

GetVersionInfoFrom builds an Info from an explicit BuildInfo value. Passing nil returns an Info with all VCS fields set to "unknown" and current runtime values for GoVersion, Compiler, and Platform. This is useful for testing without touching global state.

func (*Info) JSONString

func (i *Info) JSONString() (string, error)

JSONString returns the JSON representation of the version info.

func (*Info) String

func (i *Info) String() string

String returns the string representation of the version info.

type Option

type Option func(i *Info)

Option can be used to customize the Info after it is gathered from the environment.

func WithASCIIName

func WithASCIIName(name string) Option

WithASCIIName allows you to add an ASCII art of the name.

func WithAppDetails

func WithAppDetails(name, description, url string) Option

WithAppDetails allows setting the app name and description.

func WithBuiltBy

func WithBuiltBy(name string) Option

WithBuiltBy allows to set the builder name/builder system name.

Jump to

Keyboard shortcuts

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