-- import "github.com/kokizzu/gotro/L"
const WebBR = "\n<br/>"
var BgRed, BgGreen (func(format string, a ...any) string)
var CPU_PERCENT, RAM_PERCENT float64
var CPU_STAT2, CPU_STAT4, CPU_STAT5, LAST_STAT7 int64
var DEBUG bool
var FILE_PATH string
var GO_PATH string
var GO_ROOT string
var IsError = DefaultIsError
IsError print error
var LAST_CPU_CALL, LAST_RAM_CALL int64
var LOG *logging.Logger
var NUM_CPU float64
var TIMETRACK_MIN_DURATION float64
func CheckIf(isErr bool, msg string, args ...any) bool
CheckIf print error
func CreateDir(path string) bool
CreateDir create directory recursively
func CreateFile(path string, content string) bool
CreateFile create file with specific content
func DefaultIsError(err error, msg string, args ...any) bool
DefaultIsError function that prints error with stacktrace
func Describe(args ...any)
Describe pretty print any variable
func FileEmpty(name string) bool
FileEmpty check file missing or has zero size
func FileExists(name string) bool
FileExists check file exists
func LogTrack(start time.Time, name string) float64
LogTrack return elapsed time in ms, show 3nd level, returns in ms
func Panic(msg string, args ...any)
PanicIf print error message and exit program
func PanicIf(err error, msg string, args ...any)
PanicIf print error message and exit program
func ParentDescribe(args ...any)
ParentDescribe describe anything
func PercentCPU() float64
PercentCPU get CPU usage percentage
L.PercentCPU()
func PercentRAM() float64
PercentRAM get RAM usage percentage
L.PercentRAM()
func PipeRunCmd(cmd string, args ...string) error
PipeRunCmd run cmd and pipe to stdout
func Print(any ...any)
Print replacement for fmt.Println, gives line number
func PrintParent(any ...any)
PrintParent print but show grandparent caller function
func ReadFile(path string) string
ReadFile read file content as string
func ReadFileLines(path string, eachLineFunc func(line string) (exitEarly bool)) (ok bool)
ReadFileLines read file content line by line
func RunCmd(cmd string, args ...string) (output []byte)
RunCmd execute command and return output
func StackTrace(start int) string
StackTrace get a stacktrace as string
L.StackTrace(0) // until current function
L.StackTrace(1) // until function that call this function
func TimeTrack(start time.Time, name string) float64
TimeTrack return elapsed time in ms, show 1st level, returns in ms
func Trace()
Trace trace a function call
type CallInfo struct {
PackageName string
FileName string
FuncName string
Line int
}
func CallerChain(skipFrom, skipUntil int) (res []CallInfo)
CallerChain return caller chain until specific skipFrom 1 to 2 will return from parent caller until grandparent
func CallerInfo(skip ...int) (caller *CallInfo)
CallerInfo return caller info default skip is 1, equal to parent caller
func (c *CallInfo) String() string