26 lines
498 B
Go
26 lines
498 B
Go
// Copyright 2023 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
|
|
|
package teaconst
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
var (
|
|
IsMain = checkMain()
|
|
IsDemoMode = 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, "___")
|
|
}
|