Skip to content

optiqor --version --verbose: expose commit, build date, Go version, target #10

@oksaumya

Description

@oksaumya

Summary

optiqor --version prints only the version string. The roadmap (Tier 3, todo.md) calls for --version --verbose to also surface commit SHA, build date, Go version, and target platform. This information is essential for reproducible bug reports and CI pipelines that pin exact builds.

What to do

  1. Add three ldflags-injectable package-level variables in cmd/optiqor/main.go:
    var (
        version   = "dev"
        commit    = "none"
        buildDate = "unknown"
    )
  2. Inject them in .goreleaser.yaml:
    ldflags:
      - -s -w
      - -X main.version={{.Version}}
      - -X main.commit={{.ShortCommit}}
      - -X main.buildDate={{.Date}}
    Update the Makefile build target to pass the same flags via go build -ldflags.
  3. Wire rootCmd.Version = version.
  4. optiqor --version --verbose should print:
    optiqor v0.1.0
    commit:     abc1234
    built:      2026-05-01T00:00:00Z
    go version: go1.24.0
    os/arch:    darwin/arm64
    
  5. Plain optiqor --version must still print a single line (no regression).

Acceptance criteria

  • optiqor --version still emits a single line.
  • optiqor --version --verbose emits the extended block shown above.
  • go build without ldflags shows dev / none / unknown (graceful fallback).
  • make lint test passes.

Notes

Only cmd/optiqor/main.go, .goreleaser.yaml, and the Makefile need changes. No new dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions