Skip to content

Commit

Permalink
Merge pull request #25 from avakarev/slightly-improve-version-cmd
Browse files Browse the repository at this point in the history
Slightly improve and simplify `version` command
  • Loading branch information
avakarev authored Mar 14, 2021
2 parents 0d6375b + f188a34 commit 0327d3b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ builds:
binary: dotfiles
flags:
- -trimpath
ldflags: "-s -w -X {{.Env.BUILDMETA}}.GitCommit={{.ShortCommit}} -X {{.Env.BUILDMETA}}.BuildDate={{.Date}} -X {{.Env.BUILDMETA}}.Version={{.Version}}"
ldflags: "-s -w -X {{.Env.BUILDMETA}}.Commit={{.ShortCommit}} -X {{.Env.BUILDMETA}}.Date={{.Date}} -X {{.Env.BUILDMETA}}.Version={{.Version}}"
goos:
- linux
- darwin
Expand Down
4 changes: 2 additions & 2 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ var versionCmd = &cobra.Command{
w := tabwriter.NewWriter(log.Writer(), 0, 0, 2, ' ', 0)
f := "%s\t%s\t\n"

fmt.Fprintf(w, f, "GitCommit", buildmeta.GitCommit)
fmt.Fprintf(w, f, "BuildDate", buildmeta.BuildDate)
fmt.Fprintf(w, f, "Version", buildmeta.Version)
fmt.Fprintf(w, f, "Date", buildmeta.Date)
fmt.Fprintf(w, f, "Commit", buildmeta.Commit)
fmt.Fprintf(w, f, "Compiler", buildmeta.Compiler)

w.Flush()
Expand Down
8 changes: 4 additions & 4 deletions internal/buildmeta/buildmeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import "runtime"

// Build meta information, populated at build-time
var (
GitCommit string
BuildDate string
Version string
Compiler = runtime.Version()
Version string
Date string
Commit string
Compiler = runtime.Version()
)

0 comments on commit 0327d3b

Please sign in to comment.