Skip to content

Commit 6f6891c

Browse files
authored
Merge pull request #18 from breml/parse-flag
Leave flag.Parse() for go test
2 parents 5f0030c + 9a202e9 commit 6f6891c

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

is.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,26 @@ type I struct {
7171
colorful bool
7272
}
7373

74-
var isColorful bool
74+
var noColorFlag bool
7575

7676
func init() {
77-
noColor := flag.Bool("nocolor", false, "turns off colors")
78-
flag.Parse()
79-
isColorful = !*noColor
77+
flag.BoolVar(&noColorFlag, "nocolor", false, "turns off colors")
8078
}
8179

8280
// New makes a new testing helper using the specified
8381
// T through which failures will be reported.
8482
// In strict mode, failures call T.FailNow causing the test
8583
// to be aborted. See NewRelaxed for alternative behavior.
8684
func New(t T) *I {
87-
return &I{t, t.FailNow, os.Stdout, isColorful}
85+
return &I{t, t.FailNow, os.Stdout, !noColorFlag}
8886
}
8987

9088
// NewRelaxed makes a new testing helper using the specified
9189
// T through which failures will be reported.
9290
// In relaxed mode, failures call T.Fail allowing
9391
// multiple failures per test.
9492
func NewRelaxed(t T) *I {
95-
return &I{t, t.Fail, os.Stdout, isColorful}
93+
return &I{t, t.Fail, os.Stdout, !noColorFlag}
9694
}
9795

9896
func (is *I) log(args ...interface{}) {

0 commit comments

Comments
 (0)