Skip to content

Commit

Permalink
Allow build flags to set version '-X main.Version=0.0.4 -X main.Versi…
Browse files Browse the repository at this point in the history
…onPrerelease= '
  • Loading branch information
tristanmorgan committed May 2, 2024
1 parent c1d1e34 commit 01cfb2c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/bfg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ import (
"github.com/tristanmorgan/bfg/parser"
)

var (
// Version is the main version number that is being run at the moment.
Version = "0.0.1"

// VersionPrerelease is A pre-release marker for the Version. If this is ""
// (empty string) then it means that it is a final release. Otherwise, this
// is a pre-release such as "-dev" (in development), -"beta", "-rc1", etc.
VersionPrerelease = "-dev"
)

func main() {
version := flag.Bool("version", false, "display version")
eight := flag.Bool("eight", false, "eight bit execution")
Expand All @@ -24,7 +34,7 @@ func main() {

flag.Parse()
if *version {
fmt.Println("Version 0.0.1")
fmt.Printf("Version: v%s%s\n", Version, VersionPrerelease)
os.Exit(0)
}

Expand Down

0 comments on commit 01cfb2c

Please sign in to comment.