Skip to content

Commit

Permalink
Move version extraction to init
Browse files Browse the repository at this point in the history
  • Loading branch information
5nord committed Nov 11, 2024
1 parent 7a79998 commit 0ed79a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ var (
testsFiles []string
chdir string

version = "dev"
version = "devel"
commit = "none"
date = "unknown"

Expand Down
7 changes: 4 additions & 3 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ var (

func init() {
RootCommand.AddCommand(VersionCommand)
}

func versionInfo(cmd *cobra.Command, args []string) {
if version == "dev" {
if version == "devel" {
info, ok := debug.ReadBuildInfo()
if ok && strings.HasPrefix(info.Main.Version, "v") {
version = info.Main.Version
Expand All @@ -41,5 +39,8 @@ func versionInfo(cmd *cobra.Command, args []string) {
}
}

}

func versionInfo(cmd *cobra.Command, args []string) {
fmt.Printf("ntt %v, commit %s, built at %s\n", version, commit, date)
}

0 comments on commit 0ed79a9

Please sign in to comment.