Skip to content

feat: add --version flag and ldflags-injectable version variable#33

Merged
GustyCube merged 2 commits intoGustyCube:masterfrom
yunior123:feat/version-flag
Mar 7, 2026
Merged

feat: add --version flag and ldflags-injectable version variable#33
GustyCube merged 2 commits intoGustyCube:masterfrom
yunior123:feat/version-flag

Conversation

@yunior123
Copy link
Copy Markdown
Contributor

Summary

  • Add a version variable (default "dev") that can be set at build time via -ldflags "-X main.version=v1.0.0"
  • Add a --version flag that prints the version and exits
  • Enables release pipelines to embed version info at build time

Test plan

  • go build -ldflags "-X main.version=v1.0.0" ./cmd/membraned/ && ./membraned --version → prints membraned v1.0.0
  • ./membraned --version (without ldflags) → prints membraned dev
  • Existing tests unaffected

Add a `version` variable (default "dev") that can be set at build time
via -ldflags, and a --version flag to print the version and exit. This
enables release pipelines to embed the version at build time.
Copilot AI review requested due to automatic review settings March 6, 2026 03:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds build-time version injection and a CLI flag to surface that version from the membraned binary, supporting release pipelines and easier debugging of deployed artifacts.

Changes:

  • Introduces a version variable defaulting to "dev" that can be overridden via -ldflags -X.
  • Adds a --version/-version flag to print the binary version and exit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


if *showVersion {
fmt.Printf("membraned %s\n", version)
os.Exit(0)
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

Using os.Exit(0) in main bypasses any deferred cleanup/flush that might be added before this branch in the future. Since this is a normal successful path, prefer printing the version and then return from main instead.

Suggested change
os.Exit(0)
return

Copilot uses AI. Check for mistakes.
Using return instead of os.Exit(0) respects deferred cleanup and is
the idiomatic Go pattern for normal exit from main().

Addresses Copilot review feedback on PR GustyCube#33.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@GustyCube GustyCube merged commit 092bc13 into GustyCube:master Mar 7, 2026
1 check passed
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.

3 participants