Skip to content

Commit

Permalink
Merge pull request #18 from breml/parse-flag
Browse files Browse the repository at this point in the history
Leave flag.Parse() for go test
  • Loading branch information
matryer authored Oct 19, 2018
2 parents 5f0030c + 9a202e9 commit 6f6891c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions is.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,26 @@ type I struct {
colorful bool
}

var isColorful bool
var noColorFlag bool

func init() {
noColor := flag.Bool("nocolor", false, "turns off colors")
flag.Parse()
isColorful = !*noColor
flag.BoolVar(&noColorFlag, "nocolor", false, "turns off colors")
}

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

// NewRelaxed makes a new testing helper using the specified
// T through which failures will be reported.
// In relaxed mode, failures call T.Fail allowing
// multiple failures per test.
func NewRelaxed(t T) *I {
return &I{t, t.Fail, os.Stdout, isColorful}
return &I{t, t.Fail, os.Stdout, !noColorFlag}
}

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

0 comments on commit 6f6891c

Please sign in to comment.