mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-27 01:50:30 +08:00
修复运行测试用例时init()无法起作用的Bug
This commit is contained in:
@@ -5,6 +5,7 @@ package teaconst
|
|||||||
import (
|
import (
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -15,7 +16,7 @@ var (
|
|||||||
|
|
||||||
NodeId int64 = 0
|
NodeId int64 = 0
|
||||||
NodeIdString = ""
|
NodeIdString = ""
|
||||||
IsMain = len(os.Args) == 1 || (len(os.Args) >= 2 && os.Args[1] == "pprof")
|
IsMain = checkMain()
|
||||||
|
|
||||||
GlobalProductName = nodeconfigs.DefaultProductName
|
GlobalProductName = nodeconfigs.DefaultProductName
|
||||||
|
|
||||||
@@ -24,3 +25,15 @@ var (
|
|||||||
|
|
||||||
DiskIsFast = false // 是否为高速硬盘
|
DiskIsFast = false // 是否为高速硬盘
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// 检查是否为主程序
|
||||||
|
func checkMain() bool {
|
||||||
|
if len(os.Args) == 1 ||
|
||||||
|
(len(os.Args) >= 2 && os.Args[1] == "pprof") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
exe, _ := os.Executable()
|
||||||
|
return strings.HasSuffix(exe, ".test") ||
|
||||||
|
strings.HasSuffix(exe, ".test.exe") ||
|
||||||
|
strings.Contains(exe, "___")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user