-
Notifications
You must be signed in to change notification settings - Fork 1
/
stack.go
40 lines (35 loc) · 705 Bytes
/
stack.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package errors
import (
"path"
"runtime"
"strings"
"time"
)
func fileName(src string) (goPath string, file string) {
file = src
goHomes := goEnv()
if goHomes == nil {
return
}
for _, goHome := range goHomes {
if strings.Contains(file, goHome) {
goPath = goHome
file = strings.Replace(file, path.Join(goHome, "src"), "", 1)[1:]
return
}
}
return
}
func timeNow() time.Time {
return time.Now()
}
func callers() []uintptr {
pcs := make([]uintptr, Configure().depth)
n := runtime.Callers(Configure().skip, pcs[:])
return pcs[0:n]
}
func callersByAssigned(depth int, skip int) []uintptr {
pcs := make([]uintptr, depth)
n := runtime.Callers(skip, pcs[:])
return pcs[0:n]
}