goid

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: ISC Imports: 6 Imported by: 0

Documentation

Overview

Package goid provides goid.GoID(), unique goroutine identifiers

m := map[goid.ThreadID]SomeInterface{}
m[goid.GoID()] = …

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseFirstStackLine

func ParseFirstStackLine(stackTrace string, onlyID bool) (ID ThreadID, status ThreadStatus, err error)

getID obtains gorutine ID, as of go1.18 a numeric string "1"…

Types

type Frame

type Frame struct {
	pruntime.CodeLocation
	// args like "(1, 2, 3)"
	Args string
}

func ParseStackFrame

func ParseStackFrame(twoLines []string, noArgs bool) (frame *Frame, err error)

type Stack

type Stack struct {
	// ThreadID is a unqique ID associated with this thread.
	// typically numeric string “1”…
	// it can be used as a map key or converted to string
	ID ThreadID
	// Status is typically word “running”
	Status ThreadStatus
	// IsMainThread indicates if this is the thread that launched main.main
	IsMainThread bool
	// Frames is a list of code locations for this thread.
	// [0] is the invoker of goid.NewStack().
	// last is the function starting this thread.
	// Frame.Args is invocation values like "(0x14000113040)".
	Frames []Frame
	// Creator is the code location of the go statement launching
	// this thread.
	// FuncName is "main.main()" for main thread
	Creator pruntime.CodeLocation
}

func NewStack

func NewStack(skipFrames int) (stack *Stack)

NewStack populates a Stack object with the current thread and its stack using debug.Stack

type ThreadID

type ThreadID string

ThreadID is an opaque type that uniquley identifies a thread, ie. a goroutine. pruntime.GoRoutineID obtains the ThreadID for the executing thread. ThreadID is comparable, ie. can be used as a map key. ThreadID can be cast to string

func GoID

func GoID() (threadID ThreadID)

GoID obtains a numeric string that as of Go1.18 is assigned to each goroutine. This number is an increasing unsigned integer beginning at 1 for the main invocation

type ThreadStatus

type ThreadStatus string

ThreadStatus indicates the current stat of a thread most often it is "running"

Jump to

Keyboard shortcuts

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