runt

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: ISC Imports: 6 Imported by: 0

Documentation

Overview

Package runt provides an interface to the Go standard library’s runtime package using only serializable simple types

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoRoutineID

func GoRoutineID() (ID string)

GoRoutineID 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

func Invocation

func Invocation(stackFramesToSkip int) (stackTrace string)

Invocation returns an invocation stack trace for debug printing, empty string on troubles. The result is similar to the output from debug.Stack, but has some stack frames removed. tabs are replaced by two spaces. stackFramesToSkip 0 means first frame will be the caller of Invocation "goroutine 1 [running]:\ngithub.com/haraldrudell/parl/mains.(*Executable).AddErr(0x1809300, 0x158b620, 0xc000183800, 0x1) mains.(*Executable).AddErr-executable.go:302…"

func IsRuntimeError added in v0.2.2

func IsRuntimeError(err error) (err1 runtime.Error)

IsRuntimeError determines if err’s error chain contains a runtime.Error

func IsSendOnClosedChannel added in v0.2.2

func IsSendOnClosedChannel(err error) (is bool)

IsSendOnClosedChannel determines if err’s chain contains the runtime error “send on closed channel”

Types

type CodeLocation added in v0.2.0

type CodeLocation struct {
	File string // /opt/foxyboy/sw/privates/parl/mains/executable.go
	Line int
	// package path ending in package name, optional type information, function name
	// github.com/haraldrudell/parl/mains.(*Executable).AddErr
	FuncName string
}

CodeLocation is similar to runtime.Frame, but contains basic types string and int only

func GetCodeLocation added in v0.2.0

func GetCodeLocation(rFrame *runtime.Frame) (cl *CodeLocation)

GetCodeLocation converts a runtime stack frame to a code location stack frame. runtime contains opaque types while code location consists of basic types int and string only

func NewCodeLocation added in v0.2.0

func NewCodeLocation(stackFramesToSkip int) (cl *CodeLocation)

NewCodeLocation gets data for a single stack frame. if stackFramesToSkip it returns data for the caller of NewCodeLocation

func (*CodeLocation) Base added in v0.2.0

func (cl *CodeLocation) Base() (baseName string)

Base returns base package name, an optional type name and the function name:

mains.(*Executable).AddErr

func (*CodeLocation) Name added in v0.2.0

func (cl *CodeLocation) Name() (funcName string)

FuncName returns function name, characters no space:

AddErr

func (*CodeLocation) PackFunc added in v0.2.0

func (cl *CodeLocation) PackFunc() (packageDotFunction string)

PackFunc return base package name and function:

mains.AddErr

func (*CodeLocation) Package added in v0.2.0

func (cl *CodeLocation) Package() (funcName string)

Package return base package name, a single word of characters with no space:

mains

func (*CodeLocation) Short added in v0.2.0

func (cl *CodeLocation) Short() (funcName string)

Short returns base package name, an optional type name and the function name, base filename and line number:

mains.(*Executable).AddErr-executable.go:25

func (CodeLocation) String added in v0.2.0

func (cl CodeLocation) String() string

String returns a two-line string representation suitable for a multi-line stack trace. Typical output:

github.com/haraldrudell/parl/error116.(*TypeName).FuncName\n
  /opt/sw/privates/parl/error116/codelocation_test.go:20

Jump to

Keyboard shortcuts

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