Skip to content

Commit 06f60b3

Browse files
authored
Merge pull request #528 from alebcay/configurable-version
Allow version to be configured at build time
2 parents c4a0df2 + 47842db commit 06f60b3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

cmd/main.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"gotest.tools/gotestsum/testjson"
2020
)
2121

22+
var version = ""
23+
2224
func Run(name string, args []string) error {
2325
flags, opts := setupFlags(name)
2426
switch err := flags.Parse(args); {
@@ -33,11 +35,14 @@ func Run(name string, args []string) error {
3335

3436
switch {
3537
case opts.version:
36-
info, ok := debug.ReadBuildInfo()
37-
if !ok {
38-
return fmt.Errorf("failed to read version info")
38+
if len(version) == 0 {
39+
info, ok := debug.ReadBuildInfo()
40+
if !ok {
41+
return fmt.Errorf("failed to read version info")
42+
}
43+
version = info.Main.Version
3944
}
40-
fmt.Fprintf(os.Stdout, "gotestsum version %s\n", info.Main.Version)
45+
fmt.Fprintf(os.Stdout, "gotestsum version %s\n", version)
4146
return nil
4247
case opts.watch:
4348
return runWatcher(opts)

0 commit comments

Comments
 (0)