Skip to content

refactor: use Go native build info for commit and date#47

Merged
fank merged 2 commits intomainfrom
claude/use-native-go-build-info
Apr 12, 2026
Merged

refactor: use Go native build info for commit and date#47
fank merged 2 commits intomainfrom
claude/use-native-go-build-info

Conversation

@fank
Copy link
Copy Markdown
Member

@fank fank commented Apr 12, 2026

Summary

  • Replace ldflags injection of commit and date with runtime/debug.ReadBuildInfo() which Go embeds automatically from VCS
  • Remove BuildInfo struct — version is now passed as a string, commit/date derived from runtime/debug
  • Only version remains as an ldflag (no native way to get the git tag at runtime)
  • Aligns the build pattern across all three CLIs (esq, atl, n8nctl) to use identical ldflags: -X main.version={{.Version}}

Test plan

  • go vet ./... passes
  • go test ./... passes (all existing tests unaffected)
  • Local build shows correct commit hash and build date from VCS
  • Version injection via ldflag still works
  • -s -w stripping does NOT affect runtime/debug build info

Replace ldflags injection of commit and date with runtime/debug.ReadBuildInfo(),
which Go embeds automatically from VCS. Only version remains as an ldflag since
there is no native way to get the git tag at runtime.

This aligns the build pattern across all three CLIs (esq, atl, n8nctl).
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the CLI to dynamically retrieve VCS information (commit hash and build date) using the runtime/debug package instead of relying on ldflags during the build process. The BuildInfo struct has been removed, and a new vcsInfo function extracts metadata directly from the binary's build information. Feedback was provided to enhance the vcsInfo function by checking the vcs.modified flag to indicate whether the binary was built from a 'dirty' repository state.

@github-actions
Copy link
Copy Markdown

Merging this branch will not change overall coverage

Impacted Packages Coverage Δ 🤖
github.com/enthus-appdev/atl-cli/cmd/atl 0.00% (ø)
github.com/enthus-appdev/atl-cli/internal/cmd 0.00% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/enthus-appdev/atl-cli/cmd/atl/main.go 0.00% (ø) 3 (-1) 0 3 (-1)
github.com/enthus-appdev/atl-cli/internal/cmd/root.go 0.00% (ø) 46 (+16) 0 46 (+16)

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

@fank fank merged commit ae0cd4d into main Apr 12, 2026
11 checks passed
@fank fank deleted the claude/use-native-go-build-info branch April 12, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant