Skip to content

Commit

Permalink
Move version out of main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
iBug committed Jan 17, 2024
1 parent 98125fd commit 0f1710b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import (
"github.com/spf13/cobra"
)

var Version string
var versionCmd = &cobra.Command{
Use: "version",
Short: "Show version",
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {
cmd.Println(cmd.Root().Name(), Version)
cmd.Println(cmd.Root().Name(), version)
},
}

Expand Down
6 changes: 6 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package cmd

import _ "unsafe"

//go:linkname version main.version
var version string = "<unknown>"
3 changes: 0 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import (
"github.com/USTC-vlab/vct/cmd"
)

var version string = "<unknown>"

func main() {
cmd.Version = version
if err := cmd.MakeCmd().Execute(); err != nil {
os.Exit(1)
}
Expand Down

0 comments on commit 0f1710b

Please sign in to comment.