goroutines

package
v0.0.0-...-052fa94 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 1

README

Package cloudeng.io/debug/goroutines

import cloudeng.io/debug/goroutines

Functions

Func CompactTemplate
func CompactTemplate() (*template.Template, error)

CompactTemplate returns a single-line-per-frame representation template that emits concise goroutine information.

Func Format
func Format(gs ...*Goroutine) string

Format formats Goroutines back into the normal string representation.

Func FormatWithTemplate
func FormatWithTemplate(tmpl *template.Template, gs ...*Goroutine) (string, error)

FormatWithTemplate renders a collection of goroutines using the supplied template. The template is executed once for each line that would appear in the textual stack trace: the goroutine header, each frame, and the optional creator frame. The provided TemplateData exposes the raw goroutine/frame values along with helper booleans that enable conditional formatting from the template itself.

Func PanicTemplate
func PanicTemplate() (*template.Template, error)

PanicTemplate returns a template that mimics the formatting produced by a Go panic stack trace. The returned template is a clone of an internal instance, so callers may modify it without affecting future calls.

Types

Type Frame
type Frame struct {
	Call   string
	File   string
	Line   int64
	Offset int64
}

Frame represents a single stack frame.

Type Goroutine
type Goroutine struct {
	ID      int64
	State   string
	Stack   []*Frame
	Creator *Frame
}

Goroutine represents a single goroutine.

Functions
func Get(ignore ...string) ([]*Goroutine, error)

Get gets a set of currently running goroutines and parses them into a structured representation. Any goroutines that match the ignore list are ignored.

func Parse(buf []byte, ignore ...string) ([]*Goroutine, error)

Parse parses a stack trace into a structure representation.

Type TemplateData
type TemplateData struct {
	Goroutine *Goroutine
	Frame     *Frame

	GoroutineIndex int
	GoroutineCount int
	FrameIndex     int
	FrameCount     int

	IsHeader         bool
	IsFrame          bool
	IsCreator        bool
	IsFirstGoroutine bool
	IsLastGoroutine  bool
	IsFirstFrame     bool
	IsLastFrame      bool
	HasFrames        bool
	HasCreator       bool
	HasOffset        bool
	OffsetHex        string
}

TemplateData provides the context passed to templates executed by FormatWithTemplate. Fields are exported so they can be accessed from the template, including convenience booleans describing the position of the current line.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompactTemplate

func CompactTemplate() (*template.Template, error)

CompactTemplate returns a single-line-per-frame representation template that emits concise goroutine information.

func Format

func Format(gs ...*Goroutine) string

Format formats Goroutines back into the normal string representation.

func FormatWithTemplate

func FormatWithTemplate(tmpl *template.Template, gs ...*Goroutine) (string, error)

FormatWithTemplate renders a collection of goroutines using the supplied template. The template is executed once for each line that would appear in the textual stack trace: the goroutine header, each frame, and the optional creator frame. The provided TemplateData exposes the raw goroutine/frame values along with helper booleans that enable conditional formatting from the template itself.

func PanicTemplate

func PanicTemplate() (*template.Template, error)

PanicTemplate returns a template that mimics the formatting produced by a Go panic stack trace. The returned template is a clone of an internal instance, so callers may modify it without affecting future calls.

Types

type Frame

type Frame struct {
	Call   string
	File   string
	Line   int64
	Offset int64
}

Frame represents a single stack frame.

type Goroutine

type Goroutine struct {
	ID      int64
	State   string
	Stack   []*Frame
	Creator *Frame
}

Goroutine represents a single goroutine.

func Get

func Get(ignore ...string) ([]*Goroutine, error)

Get gets a set of currently running goroutines and parses them into a structured representation. Any goroutines that match the ignore list are ignored.

func Parse

func Parse(buf []byte, ignore ...string) ([]*Goroutine, error)

Parse parses a stack trace into a structure representation.

type TemplateData

type TemplateData struct {
	Goroutine *Goroutine
	Frame     *Frame

	GoroutineIndex int
	GoroutineCount int
	FrameIndex     int
	FrameCount     int

	IsHeader         bool
	IsFrame          bool
	IsCreator        bool
	IsFirstGoroutine bool
	IsLastGoroutine  bool
	IsFirstFrame     bool
	IsLastFrame      bool
	HasFrames        bool
	HasCreator       bool
	HasOffset        bool
	OffsetHex        string
}

TemplateData provides the context passed to templates executed by FormatWithTemplate. Fields are exported so they can be accessed from the template, including convenience booleans describing the position of the current line.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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