From 72f19274ad8b299bc696d162bf1a15d87970a596 Mon Sep 17 00:00:00 2001 From: yedf2 <120050102@qq.com> Date: Sat, 4 Sep 2021 08:01:06 +0800 Subject: [PATCH] goreleaser ok --- common/utils.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/utils.go b/common/utils.go index 1f86e05..d93fea1 100644 --- a/common/utils.go +++ b/common/utils.go @@ -7,6 +7,7 @@ import ( "os" "path/filepath" "runtime" + "strings" "time" "github.com/gin-gonic/gin" @@ -71,5 +72,9 @@ func MustGetwd() string { // GetCurrentCodeDir 获取当前源代码的目录,主要用于测试时,查找相关文件 func GetCurrentCodeDir() string { _, file, _, _ := runtime.Caller(1) - return filepath.Dir(file) + wd := MustGetwd() + if strings.HasSuffix(wd, "/test") { + wd = filepath.Dir(wd) + } + return wd + "/" + filepath.Base(filepath.Dir(file)) }