Skip to content

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

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#8
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
  • 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
  • Local build shows correct commit hash and build date from VCS
  • Version injection via ldflag still works: go build -ldflags "-s -w -X main.version=1.2.0"
  • -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

@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 versioning system to retrieve VCS information at runtime using the runtime/debug package instead of relying on build-time ldflags. The vcsInfo function was introduced to extract the commit hash and build date directly from the binary's build info. Feedback suggests enhancing this function to check the vcs.modified flag, which would allow the version output to indicate if the binary was built from a repository with uncommitted changes.

@fank fank merged commit 3f338c3 into main Apr 12, 2026
6 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