From c530d63e751cf0d1c6e2986368ef92b3eb128483 Mon Sep 17 00:00:00 2001 From: 180909 Date: Thu, 24 Nov 2022 19:12:42 +0800 Subject: [PATCH] chore(cmd): use t.Cleanup (#2537) --- cmd/kratos/internal/base/mod_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/kratos/internal/base/mod_test.go b/cmd/kratos/internal/base/mod_test.go index 577896b03..1cf4be968 100644 --- a/cmd/kratos/internal/base/mod_test.go +++ b/cmd/kratos/internal/base/mod_test.go @@ -18,8 +18,6 @@ func TestModulePath(t *testing.T) { t.Fatal(err) } - defer os.RemoveAll("/tmp/test_mod") - f, err := os.Create("/tmp/test_mod/go.mod") if err != nil { t.Fatal(err) @@ -38,6 +36,8 @@ go 1.16` t.Fatal(err) } if p != "github.com/go-kratos/kratos/v2" { - t.Fatalf("want: %s, got: %s", "module github.com/go-kratos/kratos/v2", p) + t.Fatalf("want: %s, got: %s", "github.com/go-kratos/kratos/v2", p) } + + t.Cleanup(func() { os.RemoveAll("/tmp/test_mod") }) }