Repository: uber-go/fx
Pull request #753 (2021-07-01 02:50:28)

Enable goleak in all packages
This updates goleak version to the most recent version, and enable it in all packages.

Refs GO-687

codecov[bot]: # [Codecov](https://codecov.io/gh/uber-go/fx/pull/753?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go) Report
> Merging [#753](https://codecov.io/gh/uber-go/fx/pull/753?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go) (a4b62cc) into [master](https://codecov.io/gh/uber-go/fx/commit/7223c24e6280e6b8d7097bc36105f8cdd0333491?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go) (7223c24) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/uber-go/fx/pull/753/graphs/tree.svg?width=650&height=150&src=pr&token=PYY9PSfaC6&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go)](https://codecov.io/gh/uber-go/fx/pull/753?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go)

```diff
@@           Coverage Diff           @@
##           master     #753   +/-   ##
=======================================
  Coverage   97.83%   97.83%           
=======================================
  Files          22       22           
  Lines         509      509           
=======================================
  Hits          498      498           
  Misses          9        9           
  Partials        2        2           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/uber-go/fx/pull/753?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/uber-go/fx/pull/753?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go). Last update [7223c24...a4b62cc](https://codecov.io/gh/uber-go/fx/pull/753?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=uber-go).


Patch:
diff --git a/go.mod b/go.mod
index 8fb4a2f..59e51c0 100644
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@ go 1.13
 require (
 	github.com/stretchr/testify v1.4.0
 	go.uber.org/dig v1.11.0
-	go.uber.org/goleak v0.10.0
+	go.uber.org/goleak v1.1.10
 	go.uber.org/multierr v1.5.0
 	go.uber.org/zap v1.16.0
 	golang.org/x/sys v0.0.0-20190412213103-97732733099d
diff --git a/go.sum b/go.sum
index e75a858..e1f9b65 100644
--- a/go.sum
+++ b/go.sum
@@ -23,8 +23,8 @@ go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk=
 go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
 go.uber.org/dig v1.11.1-0.20210622212612-931c2ba30782 h1:wfMqAcA7VmYM63riKRCFC2yNFtoRf5Fmg2TsEao3t+w=
 go.uber.org/dig v1.11.1-0.20210622212612-931c2ba30782/go.mod h1:X34SnWGr8Fyla9zQNO2GSO2D+TIuqB14OS8JhYocIyw=
-go.uber.org/goleak v0.10.0 h1:G3eWbSNIskeRqtsN/1uI5B+eP73y3JUuBsv9AZjehb4=
-go.uber.org/goleak v0.10.0/go.mod h1:VCZuO8V8mFPlL0F5J5GK1rtHV3DrFcQ1R8ryq7FK0aI=
+go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0=
+go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
 go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A=
 go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
 go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4=
@@ -48,8 +48,9 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3
 golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
 golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
-golang.org/x/tools v0.0.0-20191030062658-86caa796c7ab h1:tpc/nJ4vD66vAk/2KN0sw/DvQIz2sKmCpWvyKtPmfMQ=
 golang.org/x/tools v0.0.0-20191030062658-86caa796c7ab/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191108193012-7d206e10da11 h1:Yq9t9jnGoR+dBuitxdo9l6Q7xh/zOyNnYUtDKaQ3x0E=
+golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=


Test patch:
diff --git a/app_test.go b/app_test.go
index b85343a..94ca2da 100644
--- a/app_test.go
+++ b/app_test.go
@@ -35,6 +35,7 @@ import (
 	"go.uber.org/fx/fxevent"
 	"go.uber.org/fx/fxtest"
 	"go.uber.org/fx/internal/fxlog"
+	"go.uber.org/goleak"
 	"go.uber.org/multierr"
 )
 
@@ -476,8 +477,9 @@ func TestAppStart(t *testing.T) {
 		blocker := func(lc Lifecycle) *A {
 			lc.Append(
 				Hook{
-					OnStart: func(context.Context) error {
-						select {}
+					OnStart: func(ctx context.Context) error {
+						<-ctx.Done()
+						return ctx.Err()
 					},
 				},
 			)
@@ -656,7 +658,10 @@ func TestAppStart(t *testing.T) {
 
 func TestAppStop(t *testing.T) {
 	t.Run("Timeout", func(t *testing.T) {
-		block := func(context.Context) error { select {} }
+		block := func(ctx context.Context) error {
+			<-ctx.Done()
+			return ctx.Err()
+		}
 		app := fxtest.New(t, Invoke(func(l Lifecycle) {
 			l.Append(Hook{OnStop: block})
 		}))
@@ -944,6 +949,10 @@ func TestOptionString(t *testing.T) {
 	}
 }
 
+func TestMain(m *testing.M) {
+	goleak.VerifyTestMain(m)
+}
+
 type testLogger struct{ t *testing.T }
 
 func (l testLogger) Printf(s string, args ...interface{}) {
diff --git a/fxevent/event_test.go b/fxevent/event_test.go
index 93bbb48..4172628 100644
--- a/fxevent/event_test.go
+++ b/fxevent/event_test.go
@@ -22,6 +22,8 @@ package fxevent
 
 import (
 	"testing"
+
+	"go.uber.org/goleak"
 )
 
 // TestForCoverage adds coverage for own sake.
@@ -46,3 +48,7 @@ func TestForCoverage(t *testing.T) {
 		e.event()
 	}
 }
+
+func TestMain(m *testing.M) {
+	goleak.VerifyTestMain(m)
+}
diff --git a/fxtest/lifecycle_test.go b/fxtest/lifecycle_test.go
index 1e22b84..a081ee9 100644
--- a/fxtest/lifecycle_test.go
+++ b/fxtest/lifecycle_test.go
@@ -34,8 +34,6 @@ import (
 )
 
 func TestLifecycle(t *testing.T) {
-	defer goleak.VerifyNoLeaks(t)
-
 	t.Run("Success", func(t *testing.T) {
 		spy := newTB()
 
@@ -195,3 +193,7 @@ func TestPanicT(t *testing.T) {
 		assert.Equal(t, "test lifecycle failed", pval)
 	})
 }
+
+func TestMain(m *testing.M) {
+	goleak.VerifyTestMain(m)
+}
diff --git a/internal/fxlog/fxlog_test.go b/internal/fxlog/fxlog_test.go
index 91aed05..b747e4f 100644
--- a/internal/fxlog/fxlog_test.go
+++ b/internal/fxlog/fxlog_test.go
@@ -25,6 +25,7 @@ import (
 
 	"github.com/stretchr/testify/assert"
 	"go.uber.org/fx/internal/testutil"
+	"go.uber.org/goleak"
 )
 
 func TestNew(t *testing.T) {
@@ -32,3 +33,7 @@ func TestNew(t *testing.T) {
 		DefaultLogger(testutil.WriteSyncer{T: t})
 	})
 }
+
+func TestMain(m *testing.M) {
+	goleak.VerifyTestMain(m)
+}
diff --git a/internal/fxreflect/fxreflect_test.go b/internal/fxreflect/fxreflect_test.go
index f2aaa36..3b8cd3e 100644
--- a/internal/fxreflect/fxreflect_test.go
+++ b/internal/fxreflect/fxreflect_test.go
@@ -24,6 +24,7 @@ import (
 	"testing"
 
 	"github.com/stretchr/testify/assert"
+	"go.uber.org/goleak"
 )
 
 func TestCaller(t *testing.T) {
@@ -85,3 +86,7 @@ func TestSanitizeFuncNames(t *testing.T) {
 		})
 	}
 }
+
+func TestMain(m *testing.M) {
+	goleak.VerifyTestMain(m)
+}
diff --git a/internal/lifecycle/lifecycle_test.go b/internal/lifecycle/lifecycle_test.go
index b5354fc..3691be8 100644
--- a/internal/lifecycle/lifecycle_test.go
+++ b/internal/lifecycle/lifecycle_test.go
@@ -29,6 +29,7 @@ import (
 	"go.uber.org/fx/fxevent"
 	"go.uber.org/fx/internal/fxlog"
 	"go.uber.org/fx/internal/testutil"
+	"go.uber.org/goleak"
 	"go.uber.org/multierr"
 )
 
@@ -218,3 +219,7 @@ func TestLifecycleStop(t *testing.T) {
 		l.Stop(context.Background())
 	})
 }
+
+func TestMain(m *testing.M) {
+	goleak.VerifyTestMain(m)
+}