Skip to content

Feat: Add a version subcommand (ldflags currently inject into a non-existent package) #27

Open

Description

@LinuxSuRen

Description

transfer version does not exist — an unknown command falls straight into panic():

$ transfer version
Error: unknown command "version" for "transfer"
panic: unknown command "version" for "transfer"

.goreleaser.yml tries to inject the version via ldflags into github.com/linuxsuren/cobra-extension/version, but that module is neither imported nor present in go.mod/go.sum — the injection is dead, and nothing in the binary prints the value anyway.

Technical requirement

cobra (rootCmd.Version / a small version subcommand), Go build-time variable injection.

Expect

  • transfer version prints a semantic version plus commit and build date, e.g. v0.0.7 (a4ebe30, 2022-09-26),
  • the value comes from goreleaser ldflags pointed at a package that actually exists (main), with a dev fallback for source builds,
  • --version on the root command works too.

Potential TODO list

  • add version/commit/date vars in main and a version subcommand
  • fix the goreleaser ldflags target package
  • stop using panic(err) for CLI errors while at it (print and exit non-zero)

Pattern is well established in other linuxsuren CLIs — good first issue.

Activity

  1. added
    enhancement
    good first issue
    on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issue

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions