Skip to content

Commit

Permalink
feat: version info
Browse files Browse the repository at this point in the history
Signed-off-by: Batuhan Apaydın <[email protected]>
  • Loading branch information
developer-guy committed Sep 30, 2021
1 parent 3ee0e39 commit 44a447d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ builds:
- linux
- windows
- darwin
ldflags:
- -s -w -X github.com/GoTurkiye/hello-world-cli/cmd.GitCommit={{ .Commit }} -X github.com/GoTurkiye/hello-world-cli/cmd.Version={{ .Version }}
archives:
- replacements:
darwin: Darwin
Expand Down
6 changes: 6 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ import (
"github.com/spf13/viper"
)

var (
GitCommit string
Version string
)

var cfgFile string

// rootCmd represents the base command when called without any subcommands
Expand All @@ -40,6 +45,7 @@ to quickly create a Cobra application.`,
// Uncomment the following line if your bare application
// has an action associated with it:
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Working version: %s and commit: %s\n", Version, GitCommit)
fmt.Fprintf(cmd.OutOrStdout(), "Merhaba Go Türkiye!!!")
},
}
Expand Down

0 comments on commit 44a447d

Please sign in to comment.