Problem
The version information added in #12 currently uses placeholder values. We need to inject version, commit hash, and build date at build time.
Proposed Solution
Use Go's -ldflags during build to inject version information:
go build -ldflags "-X main.Version=${VERSION} -X main.Commit=${COMMIT} -X main.BuildDate=${DATE}"
Implementation Details
- Update Makefile/build script to use ldflags
- Extract version from git tags (e.g.,
git describe --tags)
- Extract commit hash from git (e.g.,
git rev-parse HEAD)
- Generate build date (e.g.,
date -u +"%Y-%m-%dT%H:%M:%SZ")
Benefits
- No need to manually update version in code
- Accurate build metadata for debugging
- Follows Go best practices for versioning
Problem
The version information added in #12 currently uses placeholder values. We need to inject version, commit hash, and build date at build time.
Proposed Solution
Use Go's
-ldflagsduring build to inject version information:go build -ldflags "-X main.Version=${VERSION} -X main.Commit=${COMMIT} -X main.BuildDate=${DATE}"Implementation Details
git describe --tags)git rev-parse HEAD)date -u +"%Y-%m-%dT%H:%M:%SZ")Benefits