runtimeutil

package
v0.0.0-...-ba7cdbd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2014 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package runtimeutil contains some utility functions for formatting stack traces and source code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatCaller

func FormatCaller(skip int, count int, numbers bool, highlight bool) (string, string)

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

func FormatCallerHTML(skip int, count int, numbers bool, highlight bool) (string, template.HTML)

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

func FormatStack(skip int) string

FormatStack returns the current call stack formatted as a string. The skip argument indicates how many frames should be omitted.

func FormatStackHTML

func FormatStackHTML(skip int) template.HTML

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

func GetPanic() (int, int, uintptr, bool)

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

func PanicLocation() (file string, line int, ok bool)

PanicLocation returns the panic location. If ok is false, the location could not be determined.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL