From b1e624a58cdfc6e187618cb8d9b436e790915a25 Mon Sep 17 00:00:00 2001 From: Sourcegraph Bot Date: Tue, 28 Apr 2020 16:20:54 +0000 Subject: [PATCH] Use t.Cleanup instead of defer in Golang code tests --- event_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/event_test.go b/event_test.go index b1445a19..26c407d3 100644 --- a/event_test.go +++ b/event_test.go @@ -84,9 +84,9 @@ func TestUnmarshalEvent(t *testing.T) { func TestUnmarshalEvents(t *testing.T) { origRegisteredEvents := registeredEvents - defer func() { + t.Cleanup(func() { registeredEvents = origRegisteredEvents - }() + }) registeredEvents = make(map[string]Event) RegisterEvent(dummyEvent{})