Skip to content

Commit 2d8ab1b

Browse files
committed
Fix #44: Integrate the version information into the binary to support 3rd party packaging
1 parent bf4f9ef commit 2d8ab1b

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

main.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
package main
22

33
import (
4+
_ "embed"
45
"fmt"
56
"github.com/sibprogrammer/xq/cmd"
7+
"strings"
68
)
79

810
var (
9-
commit = "000000"
10-
date = "unknown"
11-
version = "0.0.0"
11+
commit = "000000"
12+
date = ""
1213
)
1314

15+
//go:embed version
16+
var version string
17+
1418
func main() {
15-
cmd.Version = fmt.Sprintf("%s (%s, %s)", version, date, commit)
19+
fullVersion := strings.TrimSpace(version)
20+
if date != "" {
21+
fullVersion += fmt.Sprintf(" (%s, %s)", date, commit)
22+
}
23+
cmd.Version = fullVersion
1624
cmd.Execute()
1725
}

version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.2.2

0 commit comments

Comments
 (0)