version

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package version implements the "version" command, which prints the application's build version and — when --verbose is set — VCS metadata (version control system, commit revision, and commit timestamp). Output format is selectable via --format: human-readable text (default) or JSON.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCmd

func NewCmd(f *cmdutil.Factory, runFn ...func(context.Context, *Options) error) *cli.Command

NewCmd constructs the "version" command. The optional runFn parameter allows tests to intercept execution and inspect the populated Options without running the command's business logic.

Types

type Options

type Options struct {
	// IO provides stdout/stderr writers for output.
	IO *iostreams.IOStreams

	// AppName is the application binary name, displayed in the version line.
	AppName string

	// Version is the application's build version string.
	Version string

	// OS is the operating system target (e.g., "linux", "darwin").
	// Injected from runtime.GOOS so tests can control it.
	OS string

	// Arch is the architecture target (e.g., "amd64", "arm64").
	// Injected from runtime.GOARCH so tests can control it.
	Arch string

	// BuildInfo holds VCS metadata (system name, commit, timestamp) embedded
	// by the Go toolchain at build time.
	BuildInfo cmdutil.BuildInfo

	// Verbose controls whether VCS build metadata is displayed.
	Verbose bool

	// JSON selects machine-readable JSON output instead of the default human-readable text.
	JSON bool
}

Options holds the dependencies and flag values for the version command.

Jump to

Keyboard shortcuts

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