From ed2b3cfe804b4a7c1629b7ce9d920a313c662665 Mon Sep 17 00:00:00 2001 From: henrylee2cn Date: Wed, 18 Aug 2021 17:44:42 +0800 Subject: [PATCH] chore: add IS_GO_TEST Change-Id: If8b912fca32c318f47972a4b424f39ab555f236c --- gotest.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gotest.go b/gotest.go index ddf48be..f2ec806 100644 --- a/gotest.go +++ b/gotest.go @@ -16,6 +16,8 @@ func init() { isGoTest = checkGoTestEnv() } +const IS_GO_TEST = "IS_GO_TEST" + func checkGoTestEnv() bool { for _, arg := range os.Args[1:] { for _, s := range []string{ @@ -33,6 +35,7 @@ func checkGoTestEnv() bool { } } } - return false + env := os.Getenv(IS_GO_TEST) + return env == "1" || env == "true" // return strings.HasSuffix(os.Args[0], ".test") }