1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Package debug contains facilities for programs to debug themselves while
14 // PrintStack prints to standard error the stack trace returned by runtime.Stack.
16 os.Stderr.Write(Stack())
19 // Stack returns a formatted stack trace of the goroutine that calls it.
20 // It calls runtime.Stack with a large enough buffer to capture the entire trace.
22 buf := make([]byte, 1024)
24 n := runtime.Stack(buf, false)
28 buf = make([]byte, 2*len(buf))