mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
29 lines
770 B
Go
29 lines
770 B
Go
// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
|
//
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
// If a copy of the MIT was not distributed with this file,
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
|
|
package gutil
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gogf/gf/internal/debug"
|
|
)
|
|
|
|
const (
|
|
gFILTER_KEY = "/gf/util/gutil/gutil"
|
|
)
|
|
|
|
// PrintStack prints to standard error the stack trace returned by runtime.Stack.
|
|
func PrintStack(skip ...int) {
|
|
fmt.Print(Stack(skip...))
|
|
}
|
|
|
|
// Stack returns a formatted stack trace of the goroutine that calls it.
|
|
// It calls runtime.Stack with a large enough buffer to capture the entire trace.
|
|
func Stack(skip ...int) string {
|
|
return debug.StackWithFilter(gFILTER_KEY, skip...)
|
|
}
|