Standard library / runtime/debug
debug.Stack()
Returns a formatted stack trace of the calling goroutine. Treat it as sensitive diagnostic data. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func Stack() []byteReturn Value
[]byte
Formatted stack trace bytes of the current goroutine.
Working Example
Example Snippetgo
package main
import ( "fmt" "runtime/debug" "strings")
func main() { fmt.Println(strings.Contains(string(debug.Stack()), "main.main")) }