1 Star 0 Fork 0

蔡风华 / runutils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
runutils.go 656 Bytes
一键复制 编辑 原始数据 按行查看 历史
蔡风华 提交于 2021-09-26 14:52 . 1.优化时间展示样式。
package runutils
import (
"fmt"
"math"
"path"
"runtime"
"time"
)
// 获取正在运行的函数名
func RunFuncName() string {
pc := make([]uintptr, 1)
runtime.Callers(2, pc)
f := runtime.FuncForPC(pc[0])
return f.Name()
}
func RunFileAndLine() (info string) {
_, name, line, _ := runtime.Caller(1)
baseName := path.Base(name)
return fmt.Sprintf("%v#%v", baseName, line)
}
func CurrentTime() string {
t := time.Now()
ms := int64(math.Mod(float64(t.UnixNano()), float64(time.Second))) / int64(time.Millisecond)
return fmt.Sprintf("%04d-%02d-%02d %02d:%02d:%02d:%03d", t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), ms)
}
Go
1
https://gitee.com/cfh008/runutils.git
git@gitee.com:cfh008/runutils.git
cfh008
runutils
runutils
master

搜索帮助