fix: add --version flag and correct ldflags module path

- Add --version flag to CLI (closes bd-bxt)
- Fix ldflags module path: csv2excel/internal/version → code.beautifulmachines.dev/jakoubek/csv2excel/internal/version
  so build info (version, commit, date) is actually embedded into the binary
- Add mg.Deps(Build) to Install so it always builds before installing
This commit is contained in:
Oliver Jakoubek 2026-03-05 11:28:44 +01:00
commit 3c2c3cef57
2 changed files with 10 additions and 1 deletions

View file

@ -28,7 +28,7 @@ func ldflags() (string, error) {
buildDate = "unknown"
}
return fmt.Sprintf(
`-X csv2excel/internal/version.Version=%s -X csv2excel/internal/version.Commit=%s -X csv2excel/internal/version.BuildDate=%s`,
`-X code.beautifulmachines.dev/jakoubek/csv2excel/internal/version.Version=%s -X code.beautifulmachines.dev/jakoubek/csv2excel/internal/version.Commit=%s -X code.beautifulmachines.dev/jakoubek/csv2excel/internal/version.BuildDate=%s`,
version, commit, buildDate,
), nil
}
@ -77,6 +77,7 @@ func BuildWindows() error {
// Install installs the binary to $GOBIN or $GOPATH/bin.
func Install() error {
mg.Deps(Build)
fmt.Println("Installing", binaryName, "...")
flags, err := ldflags()
if err != nil {