diff --git a/cmd/formatter/colors.go b/cmd/formatter/colors.go index d7b851383..5dc336148 100644 --- a/cmd/formatter/colors.go +++ b/cmd/formatter/colors.go @@ -99,6 +99,7 @@ func cleanInfiniteGoroutine() { } func init() { + defer cleanInfiniteGoroutine() colors := map[string]colorFunc{} for i, name := range names { colors[name] = makeColorFunc(strconv.Itoa(30 + i)) @@ -131,5 +132,4 @@ func init() { } }() - defer cleanInfiniteGoroutine() } diff --git a/cmd/formatter/formatter_test.go b/cmd/formatter/formatter_test.go index 677a0658f..c672ade8e 100644 --- a/cmd/formatter/formatter_test.go +++ b/cmd/formatter/formatter_test.go @@ -75,5 +75,5 @@ func TestPrint(t *testing.T) { // Test the absence of unexpected goroutines. func TestColorsGoroutinesLeak(t *testing.T) { - defer goleak.VerifyNone(t) + goleak.VerifyNone(t) }