Skip to main content

Description

Shows the check-image version with full build information including version, commit hash, build date, Go version, and platform.

Command Syntax

check-image version [flags]

Flags

FlagTypeDefaultDescription
--shortboolfalsePrint only the version number
--output / -ostringtextOutput format: text or json

Usage Examples

Full Version Information

check-image version

Short Version

check-image version --short

JSON Output (Full)

check-image version -o json

JSON Output (Short)

check-image version --short -o json

Example Output

Text Format (Full)

check-image version v0.19.4
commit:     a1b2c3d
built at:   2026-02-18T12:34:56Z
go version: go1.26.0
platform:   linux/amd64

Text Format (Short)

v0.19.4

JSON Format (Full)

{
  "version": "v0.19.4",
  "commit": "a1b2c3d",
  "built-at": "2026-02-18T12:34:56Z",
  "go-version": "go1.26.0",
  "platform": "linux/amd64"
}

JSON Format (Short)

{
  "version": "v0.19.4"
}

Build Information

Version Components

FieldDescriptionExampleInjection Method
versionSemantic version stringv0.19.4ldflags at build time
commitGit commit hash (7 chars)a1b2c3dldflags at build time
built-atBuild timestamp (RFC3339 UTC)2026-02-18T12:34:56Zldflags at build time
go-versionGo compiler versiongo1.26.0Read from runtime.Version()
platformOS/Architecturelinux/amd64Read from runtime.GOOS/runtime.GOARCH

Version Injection

Version and build metadata are injected at build time using ldflags:
go build \
  -ldflags "-X github.com/jarfernandez/check-image/internal/version.Version=v0.1.0 \
            -X github.com/jarfernandez/check-image/internal/version.Commit=abc1234 \
            -X github.com/jarfernandez/check-image/internal/version.BuildDate=2026-02-18T12:34:56Z" \
  ./cmd/check-image

Development Builds

Binaries built without version injection will show:
  • Version: dev
  • Commit: none
  • Build Date: unknown
This is expected for:
  • go install builds from source
  • Local development builds with go build

Release Builds

Pre-built binaries from GitHub Releases include correct version information:
  • Version: semantic version tag (e.g., v0.19.4)
  • Commit: 7-character Git SHA (e.g., a1b2c3d)
  • Build Date: RFC3339 UTC timestamp

Exit Codes

Exit CodeMeaning
0Version displayed successfully
2Execution error (should not occur)

Notes

  • The version command takes no positional arguments.
  • Version information is always available, even when no Docker daemon or registry access is present.
  • Go version and platform are read from the Go runtime and do not require ldflags injection.
  • GoReleaser automatically injects version information during release builds using template variables {{.ShortCommit}} and {{.Date}}.
  • Docker images use build args (VERSION, COMMIT, BUILD_DATE) to inject version information.

Build docs developers (and LLMs) love