Documentation ¶
Overview ¶
Package runtimeutil contains some utility functions for formatting stack traces and source code.
Index ¶
- func FormatCaller(skip int, count int, numbers bool, highlight bool) (string, string)
- func FormatCallerHTML(skip int, count int, numbers bool, highlight bool) (string, template.HTML)
- func FormatSource(filename string, line int, count int, numbers bool, highlight bool) (string, error)
- func FormatSourceHTML(filename string, line int, count int, numbers bool, highlight bool) (template.HTML, error)
- func FormatStack(skip int) string
- func FormatStackHTML(skip int) template.HTML
- func FuncName(f interface{}) string
- func GetPanic() (int, int, uintptr, bool)
- func PanicLocation() (file string, line int, ok bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatCaller ¶
FormatCaller finds the caller, skipping skip frames, and then formats the source using FormatSource. The location is returned in the first string, while the formatted source is the second return parameter. See the documentation for FormatSource() for an explanation of the rest of the parameters.
func FormatCallerHTML ¶
FormatCallerHTML works like FormatCaller, but uses FormatSourceHTML rather than FormatSource
func FormatSource ¶
func FormatSource(filename string, line int, count int, numbers bool, highlight bool) (string, error)
FormatSource returns the source from filename around line formatted as HTML. The count parameter indicates the number of lines to include before and after the target line (if possible). If numbers is true, the line numbers will be preprended to each line. Finally, if highlight is true, the line passed as the second parameter with be highlighted by adding the string "<===" at its end.
func FormatSourceHTML ¶
func FormatSourceHTML(filename string, line int, count int, numbers bool, highlight bool) (template.HTML, error)
FormatSourceHTML works like FormatSource, but returns the result as HTML. Highlighting is done by wrapping the line inside a span element with its class set to "current".
func FormatStack ¶
FormatStack returns the current call stack formatted as a string. The skip argument indicates how many frames should be omitted.
func FormatStackHTML ¶
FormatStackHTML works like FormatStack, but returns its results in HTML, using <abbr> tags for displaying pointer contents (when possible).
func FuncName ¶
func FuncName(f interface{}) string
FuncName returns the name for the given function. If f is not a function or its name can't be determined an empty string is returned.
func GetPanic ¶
GetPanic returns the number of frames to skip and the PC for the uppermost panic in the call stack (there might be multiple panics when a recover() catches a panic and then panics again). The second value indicates how many stack frames should be skipped in the stacktrace (they might not always match). The last return value indicates a frame could be found.
func PanicLocation ¶
PanicLocation returns the panic location. If ok is false, the location could not be determined.
Types ¶
This section is empty.