github.com/gogf/gf@v1.16.9/errors/gerror/gerror_stack.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/gogf/gf. 6 7 package gerror 8 9 import "runtime" 10 11 // stack represents a stack of program counters. 12 type stack []uintptr 13 14 const ( 15 // maxStackDepth marks the max stack depth for error back traces. 16 maxStackDepth = 32 17 ) 18 19 // callers returns the stack callers. 20 // Note that it here just retrieves the caller memory address array not the caller information. 21 func callers(skip ...int) stack { 22 var ( 23 pcs [maxStackDepth]uintptr 24 n = 3 25 ) 26 if len(skip) > 0 { 27 n += skip[0] 28 } 29 return pcs[:runtime.Callers(n, pcs[:])] 30 }