improve error handling for gconv.Struct/ghttp.Server; add NewSkip/NewfSkip function for package gerror

This commit is contained in:
John
2020-04-28 15:04:07 +08:00
parent 9e064e2651
commit 6e7224e306
10 changed files with 180 additions and 59 deletions

View File

@ -15,8 +15,14 @@ const (
gMAX_STACK_DEPTH = 32
)
func callers() stack {
var pcs [gMAX_STACK_DEPTH]uintptr
n := runtime.Callers(3, pcs[:])
return pcs[0:n]
// callers returns the stack callers.
func callers(skip ...int) stack {
var (
pcs [gMAX_STACK_DEPTH]uintptr
n = 3
)
if len(skip) > 0 {
n += skip[0]
}
return pcs[:runtime.Callers(n, pcs[:])]
}