Skip to content

Commit d1c6686

Browse files
authored
fix default args values (#14)
1 parent a37b6ae commit d1c6686

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

main.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ import (
1616
//nolint:gochecknoglobals // must be global var
1717
var Version string
1818

19-
//nolint:gochecknoinits // relax
20-
func init() {
21-
if Version == "" {
22-
Version = "unknown-" + strconv.Itoa(int(time.Now().Unix()))
23-
}
24-
}
25-
2619
type args struct {
2720
ConfigPath string `arg:"-c,--config"`
2821
Profile string `arg:"-p,--profile" help:"path to coverage profile"`
@@ -33,8 +26,25 @@ type args struct {
3326
ThresholdTotal int `arg:"-t,--threshold-total"`
3427
}
3528

29+
func newArgs() args {
30+
return args{
31+
ConfigPath: `''`,
32+
Profile: `''`,
33+
LocalPrefix: `''`,
34+
GithubActionOutput: false,
35+
ThresholdFile: -1,
36+
ThresholdPackage: -1,
37+
ThresholdTotal: -1,
38+
}
39+
}
40+
3641
func (args) Version() string {
37-
return "go-test-coverage " + Version
42+
version := Version
43+
if version == "" {
44+
version = "unknown-" + strconv.Itoa(int(time.Now().Unix()))
45+
}
46+
47+
return "go-test-coverage " + version
3848
}
3949

4050
func (a *args) overrideConfig(cfg testcoverage.Config) testcoverage.Config {
@@ -84,7 +94,7 @@ func main() {
8494
}
8595

8696
func readConfig() (testcoverage.Config, error) {
87-
cmdArgs := args{}
97+
cmdArgs := newArgs()
8898
arg.MustParse(&cmdArgs)
8999

90100
cfg := testcoverage.Config{}

0 commit comments

Comments
 (0)