The cloudamqp CLI supports version information that can be set at build time using Go's -ldflags.
The following variables are available in cmd/version.go:
Version- The version number (e.g., "1.0.0")BuildDate- The build date (e.g., "2025-11-25")GitCommit- The git commit hash (optional)
The Makefile automatically extracts version information from git:
# Build with automatic git version
make buildOutput:
$ ./cloudamqp version
cloudamqp version v0.1.0-8-g285bd2b (2025-11-26)
https://github.com/cloudamqp/cli/releases/tag/v0.1.0-8-g285bd2b
Show version information before building:
make version-infoOverride version manually:
make build VERSION=1.0.0 BUILD_DATE=2025-11-25go build -o cloudamqp-cliOutput:
$ cloudamqp-cli version
cloudamqp version dev (development build)
go build -ldflags "\
-X cloudamqp-cli/cmd.Version=1.0.0 \
-X cloudamqp-cli/cmd.BuildDate=2025-11-25 \
-X cloudamqp-cli/cmd.GitCommit=abc123" \
-o cloudamqp-cliOutput:
$ cloudamqp-cli version
cloudamqp version 1.0.0 (2025-11-25)
https://github.com/cloudamqp/cli/releases/tag/v1.0.0
VERSION=$(git describe --tags --always --dirty)
BUILD_DATE=$(date -u +"%Y-%m-%d")
GIT_COMMIT=$(git rev-parse --short HEAD)
go build -ldflags "\
-X cloudamqp-cli/cmd.Version=${VERSION} \
-X cloudamqp-cli/cmd.BuildDate=${BUILD_DATE} \
-X cloudamqp-cli/cmd.GitCommit=${GIT_COMMIT}" \
-o cloudamqp-cliThe version can be displayed in two ways:
# Using the version command
cloudamqp version
# Using the --version or -v flag
cloudamqp --version
cloudamqp -vBoth produce identical output, similar to GitHub CLI (gh).
- name: Build
run: |
VERSION=${GITHUB_REF#refs/tags/}
BUILD_DATE=$(date -u +"%Y-%m-%d")
GIT_COMMIT=${GITHUB_SHA::7}
go build -ldflags "\
-X cloudamqp-cli/cmd.Version=${VERSION} \
-X cloudamqp-cli/cmd.BuildDate=${BUILD_DATE} \
-X cloudamqp-cli/cmd.GitCommit=${GIT_COMMIT}" \
-o cloudamqp-clibuilds:
- ldflags:
- -X cloudamqp-cli/cmd.Version={{.Version}}
- -X cloudamqp-cli/cmd.BuildDate={{.Date}}
- -X cloudamqp-cli/cmd.GitCommit={{.ShortCommit}}