Documentation ¶
Overview ¶
Package parl handles inter-thread communication and controls parallelism
parl has sub-packages augmenting the Go standard library:
perrors pfs plog pnet pos pruntime psql pstrings psyscall pterm ptime
parl has feature packages:
ev — handling of goroutine-based functions goid — unique goroutine IDs mains — functions for writing command-line utilities and services parlca — self-signed certificate authority progress — monitor work progress for a large number of threads sqlite — local SQL database threadprof — profiling and counters for what threads are doing // statuser: thread hang detector tracer — event lists by task rather than by time or thread
parl features per-writer thread-safe logging with topic and per-package output control:
Logging is to stderr except for the Out function. parl logging uses comma separator for numbers. One argument is output as string, two or more arguments is Printf. The location matched against the regular expression is full package path, optional type receiver and the funtion name: “github.com/haraldrudell/mypackage.(*MyType).MyFunc”
Out(string, ...interface{}) — Standard output Log(string, ...interface{}) — Always outputs to stderr parl.D(string, ...interface{}) — Same as Log, intended for temporary use Info(string, ...interface{}) — Informational progress messages SetSilent(true) — removes Info output IsSilent() — deteremines if Info printing applies Debug(string, ...interface{}) — only prints for locations where SetDebug(true) SetDebug(true) — Control Debug() globally, code location for all prints, long stack traces SetRegexp(regExp string) (err error) — Regular expression controlling local Debug() printing IsThisDebug() — Determines if debug is active for the executing function Console(string, ...interface{}) — terminal interactivity output
parl provides panic recovery for process and goroutines: capturing panics, annotating, retrieving and storing errors and invoking error handling functions:
func myThread(errCh chan<- error) { var err error defer close(errCh) defer parl.Recover2(parl.Annotation(), &err, func (err error) { errCh <- err}) if err = someFunc(); err != nil { err = perrors.Errorf("someFunc: %w", err) return … func myThreadSafeThread(wg *sync.WaitGroup, errs *perrors.ParlError) { // ParlError: thread-safe error store defer wg.Done() defer parl.Recover(parl.Annotation(), nil, errs.AddErrorProc) if err = someFunc(); err != nil { errs.AddError(perrors.Errorf("someFunc: %w", err)) return …
parl package features:
AtomicBool — Thread-safe boolean Closer — Deferable, panic free channel close ClosableChan — Initialization-free channel with inspectable close that does not panic Moderator — A ticketing system for limited parallelism NBChan — A non-blocking unbuffered channel with trillion-size buffer OnceChan — Initialization-free inspectable shutdown semaphore implementing Context SerialDo — Serialization of invocations WaitGroup —Inspectable WaitGroup Debouncer — Invocation debouncer, pre-generics Sprintf — Supporting thousands separator
Parl is about 9,000 lines of Go code with first line written on November 21, 2018 ¶
On March 16th, 2022, parl was open-sourced under an ISC License ¶
© 2018–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
© 2020–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/) ISC License
Index ¶
- Constants
- func AddToPanic(panicValue interface{}, additionalErr error) (err error)
- func Annotation() (annotation string)
- func Closer[T any](ch chan T, errp *error)
- func Console(format string, a ...interface{})
- func D(format string, a ...interface{})
- func Debug(format string, a ...interface{})
- func EnsureError(panicValue interface{}) (err error)
- func Errorf(format string, a ...interface{}) (err error)
- func HandleErrp(fn func(), errp *error)
- func HandlePanic(fn func()) (err error)
- func HandleParlError(fn func(), storeError func(error))
- func Info(format string, a ...interface{})
- func IsSilent() (isSilent bool)
- func IsThisDebug() bool
- func Log(format string, a ...interface{})
- func New(s string) error
- func NewDebouncer(d time.Duration, receiver ReceiverFunc, sender SenderFunc, ctx context.Context) (err error)
- func Out(format string, a ...interface{})
- func Recover(annotation string, errp *error, onError func(error))
- func Recover2(annotation string, errp *error, onError func(error))
- func SetDebug(debug bool)
- func SetRegexp(regExp string) (err error)
- func SetSilent(silent bool)
- func Sprintf(format string, a ...interface{}) string
- type AdbAdressProvider
- type AdbRequest
- type AdbResponseID
- type AdbSocketAddress
- type AdbSyncRequest
- type Adbette
- type Adbetter
- type AndroidSerial
- type AndroidStatus
- type AtomicBool
- type ClosableChan
- type Counter
- type CounterID
- type CounterValues
- type Counters
- type CountersFactory
- type Dent
- type Devicette
- type DevicetteFactory
- type FSLocation
- type FanOut
- type FanProc
- type FanThunk
- type History
- type HistoryFactory
- type Moderator
- type NBChan
- type OnceChan
- type Password
- type ReceiverFunc
- type SenderFunc
- type SerialDo
- type SerialDoEvent
- type SerialDoFunc
- type ServerFactory
- type Serverette
- type ServeretteFactory
- type Statuser
- type StatuserFactory
- type Timer
- type Tracer
- type TracerFactory
- type TracerRecord
- type TracerTaskID
- type Trackerette
- type TriggeringChan
- type Value
- type WaitGroup
Constants ¶
const ( Rfc3339s = "2006-01-02 15:04:05-07:00" Rfc3339ms = "2006-01-02 15:04:05.999-07:00" Rfc3339us = "2006-01-02 15:04:05.999999-07:00" Rfc3339ns = "2006-01-02 15:04:05.999999999-07:00" Rfc3339sz = "2006-01-02T15:04:05Z" Rfc3339msz = "2006-01-02T15:04:05.999Z" Rfc3339usz = "2006-01-02T15:04:05.999999Z" Rfc3339nsz = "2006-01-02T15:04:05.999999999Z" )
const ( SerialDoReady = 0 + iota SerialDoLaunch // from idle, now time SerialDoPending // queued up invocation, request time SerialDoPendingLaunch // launch of pending invocation, request time SerialDoIdle // busy since )
Variables ¶
This section is empty.
Functions ¶
func AddToPanic ¶
func Annotation ¶
func Annotation() (annotation string)
func Console ¶
func Console(format string, a ...interface{})
Console always print intended for command-line interactivity if debug is enabled, code location is appended
func D ¶
func D(format string, a ...interface{})
D prints to stderr with code location Thread safe. D is meant for temporary output intended to be removed before check-in
func Debug ¶
func Debug(format string, a ...interface{})
Debug outputs only if debug is configured or the code location package matches regexp
func EnsureError ¶
func EnsureError(panicValue interface{}) (err error)
func Errorf ¶
parl.Errorf offers stack traces and other rich error feattues of packages perrors and errorglue
func HandleErrp ¶ added in v0.2.2
func HandleErrp(fn func(), errp *error)
HandleErrp recovers from panics when executing fn. A panic is stored at errp using error116.AppendError()
func HandlePanic ¶
func HandlePanic(fn func()) (err error)
HandlePanic recovers from panics when executing fn. A panic is returned in err
func HandleParlError ¶ added in v0.2.2
func HandleParlError(fn func(), storeError func(error))
HandleErrp recovers from panics when executing fn. A panic is provided to the storeError function. storeError can be the thread-safe error116.ParlError.AddErrorProc()
func Info ¶
func Info(format string, a ...interface{})
Info prints unless silence has been configured with SetSilence(true) IsSilent deteremines the state of silence if debug is enabled, code location is appended
func IsThisDebug ¶
func IsThisDebug() bool
IsThisDebug returns whether debug logging is configured for the executing function
func Log ¶
func Log(format string, a ...interface{})
Log invocations always print if debug is enabled, code location is appended
func New ¶
parl.New offers stack traces and other rich error feattues of packages perrors and errorglue
func NewDebouncer ¶
func NewDebouncer(d time.Duration, receiver ReceiverFunc, sender SenderFunc, ctx context.Context) (err error)
Debouncer debounces event streams of Value
func Recover ¶
Recover recovers from a panic invoking a function no more than once. If there is *errp does not hold an error and there is no panic, onError is not invoked. Otherwise, onError is invoked exactly once. *errp is updated with a possible panic.
func Recover2 ¶
Recover2 recovers from a panic and may invoke onError multiple times. onError is invoked if there is an error at *errp and on a possible panic. *errp is updated with a possible panic.
Types ¶
type AdbAdressProvider ¶ added in v0.4.0
type AdbAdressProvider interface { // AdbSocketAddress retrievs the tcp socket address used // by a near Adbette implementation AdbSocketAddress() (socketAddress AdbSocketAddress) }
AdressProvider retrieves the address from an adb server or device so that custom devices can be created
type AdbRequest ¶ added in v0.3.0
type AdbRequest string
AdbRequest is a string formatted as an adb request. AdbRequest is only required for implementations using the Adbette protocol impementation
type AdbResponseID ¶ added in v0.4.0
type AdbResponseID string
type AdbSocketAddress ¶ added in v0.4.0
type AdbSocketAddress string
AdbSocketAddress is a tcp socket address accessible to the local host. The format is two parts separated by a colon. The first part is an IP address or hostname. The second part is a numeric port number. The empty string "" represents "localhost:5037". If the port part is missing, such as "localhost" it implies port 5037. If the host part is missing, it implies "localhost". Note that locahost is valid both for IPv4 and IPv6.
type AdbSyncRequest ¶ added in v0.4.0
type AdbSyncRequest string
type Adbette ¶ added in v0.3.0
type Adbette interface { // SendReadOkay sends a request to a remote adb endpoint. // if anything else than OKAY is received back from the // remote endpoint, err is non-nil. SendReadOkay(request AdbRequest) (err error) // ReadString reads utf-8 text up to 64 KiB-1 in length ReadString() (s string, err error) // ConnectToDevice sends a forwarding request to an adb // server to connect to one of its devices ConnectToDevice(serial AndroidSerial) (err error) // Shell executes a shell command on a device connected to the adb server. // out is a combination of stderr and stdout. // The status code from an on-device command cannot be obtained Shell(command string, reader ...func(conn io.ReadWriteCloser) (err error)) (out string, err error) // TrackDevices orders a server to emit serial number as they become available TrackDevices() (err error) // Devices lists the currently online serials Devices() (serials []AndroidSerial, err error) // DeviceStati returns all available serials and their status // The two slices correspond and are of the same length DeviceStati() (serials []AndroidSerial, stati []AndroidStatus, err error) // Closer closes an adb connection, meant to be a deferred function Closer(errp *error) // SetSync sets the protocol mode of an adb device connection to sync SetSync() (err error) // LIST is a sync request that lists file system entries in a directory of an adb device LIST(remoteDir string, dentReceiver func(mode uint32, size uint32, time uint32, byts []byte) (err error)) (err error) // RECV fetches the contents of a file on an adb device RECV(remotePath string, blobReceiver func(data []byte) (err error)) (err error) // CancelError is a value that a LIST or RECV callback routines can return to // cancel further invocations CancelError() (cancelError error) SendBlob(syncRequest AdbSyncRequest, data []byte) (err error) ReadBlob() (byts []byte, err error) ReadResponseID() (responseID AdbResponseID, err error) ReadBytes(byts []byte) (err error) SendBytes(byts []byte) (err error) }
Adbette is a minimal implementation of the adb Android debug bridge protocol. Adbette include both adb server and Android device functions. Adbette is extensible in that additional protocol features are easily implemented without concern for protocol details. to shutdown an Adbette and release its resouces, invoke the Closer method
type Adbetter ¶ added in v0.3.0
type Adbetter interface {
NewConnection(address AdbSocketAddress, ctx context.Context) (conn Adbette, err error)
}
Adbetter is a factory instance for connections featuring Adbette context is used for terminating a connection attempt. context is not retained in the connection.
type AndroidSerial ¶ added in v0.3.0
type AndroidSerial string
AndroidSerial uniquely identities an Android device. It is typically a string of a dozen or so 8-bit chanacters consisting of lower and upper case a-zA-Z0-9
type AndroidStatus ¶ added in v0.3.0
type AndroidStatus string
AndroidStatus indicates the current status of a device known to a Server or Serverette it is a single word of ANSII-set characters
const AndroidOnline AndroidStatus = "device"
AndroidOnline is the Android device status that indicates an online device
type AtomicBool ¶
type AtomicBool struct {
// contains filtered or unexported fields
}
AtomicBool is a thread-safe flag. AtomicBool requires no initialization
var isDone parl.AtomicBool if isDone.Set() // isDone was not set, but is set now … if !isDone.IsTrue() // isDone is not set
func (*AtomicBool) Clear ¶
func (ab *AtomicBool) Clear() (wasSet bool)
func (*AtomicBool) IsTrue ¶
func (ab *AtomicBool) IsTrue() (isTrue bool)
func (*AtomicBool) Set ¶
func (ab *AtomicBool) Set() (wasNotSet bool)
type ClosableChan ¶ added in v0.4.0
type ClosableChan[T any] struct { // contains filtered or unexported fields }
ClosableChan holds a channel. ClosableChan has a thread-safe re-entrant Close method closing the channel exactly once without panics. IsClosed indicates wether the channel has been closed
func NewCloser ¶ added in v0.4.0
func NewCloser[T any](ch chan T) (cl *ClosableChan[T])
NewCloser ensures a chan does not throw
func (*ClosableChan[T]) Ch ¶ added in v0.4.0
func (cl *ClosableChan[T]) Ch() (ch chan T)
Ch retrieves the channel
func (*ClosableChan[T]) Close ¶ added in v0.4.0
func (cl *ClosableChan[T]) Close(errp ...*error) (err error, didClose bool)
Close ensures the channel is closed. Close does not panic. Close is thread-safe. Close does not return until the channel is closed. Upon return, all invocations have a possible close error in err. if errp is non-nil, it is updated with error status
func (*ClosableChan[T]) IsClosed ¶ added in v0.4.0
func (cl *ClosableChan[T]) IsClosed() (isClosed bool)
IsClosed indicates whether the Close method has been invoked
type Counter ¶ added in v0.3.0
type Counter interface { Inc() (counter Counter) Dec() (counter Counter) CounterValue(reset bool) (values CounterValues) }
type CounterValues ¶ added in v0.3.0
type CountersFactory ¶ added in v0.3.0
type Dent ¶ added in v0.3.0
type Dent interface { // Name is utf-8 base path in device file system Name() (name string) // Modified is in second precision, local time zone Modified() (modified time.Time) // IsDir indicates directory. // LIST only support symbolic link, directory and regular file types IsDir() (isDir bool) // IsRegular indicates regular file, ie. not a directory or symbolic link. // LIST only support symbolic link, directory and regular file types IsRegular() (isRegular bool) // ie.not directory or symlink // Perm returns os.FileMode data. // 9-bit Unix permissions per os.FilePerm. // directory and symlink bits Perm() (perm fs.FileMode) // Size is limited to 4 GiB-1 Size() (size uint32) }
Dent is the information returned by adb ls or LIST
type Devicette ¶ added in v0.3.0
type Devicette interface { // Serial returns the serial number for this device Serial() (serial AndroidSerial) // Shell executes a shell command on the device. // The resulting socket can be obtained either using the reader callback, // which is a socket connection to the device, // or by collecting the out string. Shell(command string, reader func(conn io.ReadWriteCloser) (err error)) (out string, err error) // Pull copies a remote file or directory on the Android device to a local file system location. // the local file must not exist. Pull(remotePath, nearPath string) (err error) /* List has some peculiarities: If remoteDir is not an existing directory, an empty list is returned. Entries with insufficient permisions are ignored. Update: . and .. are removed, adb LIST ortherwise do return those. File mode: the only present type bits beyond 9-bit Unix permissions are symlink, regular file and directory. File size is limited to 4 GiB-1. Modification time resolution is second and range is confined to a 32-bit Unix timestamp. */ List(remoteDir string) (dFileInfo []Dent, err error) }
Devicette is a generic implementation of the capabilities of a device implementing the adb Android debug bridge protocol
type DevicetteFactory ¶ added in v0.4.0
type DevicetteFactory interface { // NewDevicette creates a Devicette interacting with remote adb Android Debug Bridge // devices via an adb server available at the socket address address NewDevicette(address AdbSocketAddress, serial AndroidSerial, ctx context.Context) (devicette Devicette) }
DevicetteFactory describes how Devicette objects are obtained.
type FSLocation ¶
type FSLocation interface {
Directory() (directory string)
}
type FanOut ¶
type FanOut struct { ErrCh chan error Results chan interface{} // contains filtered or unexported fields }
func (*FanOut) Do ¶
Do executes a procedure in a goroutine that has no result other than a possible non-nil error
type HistoryFactory ¶ added in v0.3.0
type Moderator ¶
type Moderator struct {
// contains filtered or unexported fields
}
Moderator invokes functions at a limited level of parallelism. It is a ticketing system
m := NewModerator(20, ctx) m.Do(func() (err error) { // waiting here for a ticket // got a ticket! … return or panic // ticket automatically returned m.String() → waiting: 2(20)
func NewModerator ¶
NewModerator creates a new Moderator used to limit parallelism
func (*Moderator) Do ¶
Do calls fn limited by the moderator’s parallelism. If the moderator is shut down, ErrModeratorShutdown is returned
type NBChan ¶ added in v0.4.0
type NBChan[T any] struct { // GetError() perrors.ParlError // possible thread panic // contains filtered or unexported fields }
NBChan is a non-blocking thread-safe channel. NBChan does not need initialization. NBChan can be used for error channels.
func NewNBChan ¶ added in v0.4.0
NewNBChan instantiates a non-blocking channel based on existing channel. NewNBChan otherwise does not need initialization and can be used like:
var nbChan NBChan[error] go wherever(nbChan.Ch())
A non-blocking channel is a trillion-buffer channel that does not block if a reader is not present
func (*NBChan[T]) Close ¶ added in v0.4.0
Close ensures the channel is closed. Close does not panic. Close is thread-safe. Close does not return until the channel is closed. Upon return, all invocations have a possible close error in err. if errp is non-nil, it is updated with error status
type OnceChan ¶ added in v0.3.0
type OnceChan struct {
// contains filtered or unexported fields
}
OnceChan is a semaphore implementing the Context with Cancel interface. Whenever a context is required for cancellation, a OnceChan can be used in its place. Unlike context, OnceChan requires no initialization. Similar to Context, OnceChan can be waited on like a channel using Done(). OnceChan can be inspected using IsDone() or Err(). OnceChan is cancelled using .Cancel()
var semaphore OnceChan go func() { <-onceChan.Done() }() … semaphore.Cancel() … semaphore.IsDone()
type ReceiverFunc ¶
type ReceiverFunc func(c <-chan time.Time, done <-chan struct{}) (which TriggeringChan, value Value)
ReceiverFunc takes two channels, listens to them and a typed channel, returns what channel triggered and a possible untyped value
type SenderFunc ¶
type SenderFunc func([]Value)
SenderFunc takes an untyped value, type asserts and sends on a typed channel
type SerialDo ¶
type SerialDo struct { ErrCh chan error ID string Wg sync.WaitGroup // contains filtered or unexported fields }
serialdo invokes method in sequence
func NewSerialDo ¶
func NewSerialDo(thunk func(), eventReceiver SerialDoFunc, ctx context.Context) (sdo *SerialDo)
NewSerialDo SerialDo. errors on sdo.ErrCh
type SerialDoEvent ¶
type SerialDoEvent uint8
type SerialDoFunc ¶
type SerialDoFunc func(SerialDoEvent, *SerialDo, *time.Time)
type ServerFactory ¶ added in v0.3.0
type ServerFactory interface { // Adb connects to an adb adb Android Debug Bridge server on a specified tcp socket Adb(address AdbSocketAddress, ctx context.Context) (server Serverette) // AdbLocalhost connects to an adb Android Debug Bridge server on the local computer AdbLocalhost(ctx context.Context) (server Serverette) }
ServerFactory describes how AdbServer objects are obtained. Such servers may use duifferent protocol implementations from Adbette
type Serverette ¶ added in v0.3.0
type Serverette interface { AdbAdressProvider // AdbSocketAddress() // DeviceSerialList lists serials for the currently online Android devices DeviceSerialList() (serials []AndroidSerial, err error) // DeviceStati lists all serials currently known to the server along with // their current status. // The two slices correspond and are of the same length DeviceStati() (serials []AndroidSerial, stati []AndroidStatus, err error) // TrackDevices emits serial numbers for devices that come online. // serials are sent on the serials channel. // if err is non-nil, set-up of failed. // The errs channel closes when watching stops // Watching is stopped by calling cancel function or when the server’s context terminates TrackDevices() (tracker Trackerette, err error) }
Serverette is a generic representation of an adb server running on a host.
command-line adb: As of Android 12, Android Debug Bridge version 1.0.41 Version 32.0.0-8006631 has the following commands are supported: devices connect disconnect pair forward ppp reverse mdns push pull sync shell emu install install-multiple install-multiple-package uninstall bugreport jdwp logcat disable-verity enable-verity keygen wait-for* get-state get-serialno get-devpath remount reboot sideload root unroot usb tcpip start-server kill-server reconnect attach detach
type ServeretteFactory ¶ added in v0.3.0
type ServeretteFactory interface { // Adb connects to an adb adb Android Debug Bridge server on a specified tcp socket. // address is a string default "localhost:5037" and default port ":5037". // adbetter is a factory for Adbette connections. NewServerette(address AdbSocketAddress, adbetter Adbetter, ctx context.Context) (server Serverette) }
ServeretteFactory is a Server connection factory for Adbette implementations
type StatuserFactory ¶ added in v0.3.0
type Timer ¶
type Timer struct { Label string // contains filtered or unexported fields }
Timer is a simple request timer
type Tracer ¶ added in v0.3.0
type Tracer interface { Assign(threadID goid.ThreadID, task TracerTaskID) (tracer Tracer) Record(threadID goid.ThreadID, text string) (tracer Tracer) Records(clear bool) (records map[TracerTaskID][]TracerRecord) }
type TracerFactory ¶ added in v0.3.0
type TracerFactory interface {
NewTracer() (tracer Tracer)
}
type TracerRecord ¶ added in v0.3.0
type TracerTaskID ¶ added in v0.3.0
type TracerTaskID string
type Trackerette ¶ added in v0.3.0
type Trackerette interface { // Serials emit serial number as online devices become available Serials() (serials <-chan AndroidSerial) // Errs is available once Serials close. It returns any errors Errs() (err error) // Cancel shuts down the Tracker Cancel() }
Trackerette represents a server connection emitting device serial numbers
type TriggeringChan ¶
type TriggeringChan uint8
const ( TimerCh TriggeringChan = iota DoneCh ValueCh )
type WaitGroup ¶ added in v0.3.0
parl.WaitGroup is like a sync.Waitgroup that can be inspected. The Waiting method returns the number of threads waited for. parl.WaitGroup requires no initialization.
var wg parl.WaitGroup wg.Add(1) … wg.Waiting()
func (*WaitGroup) NoneWaiting ¶ added in v0.3.0
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package errorglue contains helful declarations that are not important
|
Package errorglue contains helful declarations that are not important |
Package ev provides standardized goroutine management events contain thread completions, failures and any type of data items.
|
Package ev provides standardized goroutine management events contain thread completions, failures and any type of data items. |
Package evx contains declarations not essential to event handling
|
Package evx contains declarations not essential to event handling |
Package goid provides goid.GoID(), unique goroutine identifiers m := map[goid.ThreadID]SomeInterface{} m[goid.GoID()] = …
|
Package goid provides goid.GoID(), unique goroutine identifiers m := map[goid.ThreadID]SomeInterface{} m[goid.GoID()] = … |
mains
module
|
|
omaps
module
|
|
Package parlca provides a self-signed certificate authority
|
Package parlca provides a self-signed certificate authority |
Package error116 enrichens error values with string data, stack traces, associated errors, less severe warnings, thread-safe containers and comprehensive error string representations.
|
Package error116 enrichens error values with string data, stack traces, associated errors, less severe warnings, thread-safe containers and comprehensive error string representations. |
pfs
module
|
|
Package parlnet provides IP-related functions with few dependencies beyond the net package
|
Package parlnet provides IP-related functions with few dependencies beyond the net package |
Package parlos provides simplified functions related to the os package
|
Package parlos provides simplified functions related to the os package |
process
module
|
|
Package progress provides printable progress reporting for multi-threaded operations
|
Package progress provides printable progress reporting for multi-threaded operations |
Package pruntime provides an interface to the Go standard library’s runtime package using only serializable simple types Stack traces and code locations have several formats: codeLocation := pruntime.NewCodeLocation(0) codeLocation.Base() // package and type → mypackage.(*MyType).MyFunc codeLocation.PackFunc() // very brief → mypackage.MyFunc codeLocation.Name(): // function name only → MyFunc codeLocation.Short() // line, no package path → mypackage.(*MyType).MyFunc-myfile.go:19 codeLocation.Long() // uniquely identifiable → codeberg.org/haraldrudell/mypackage.(*MyType).MyFunc-myfile.go:19 codeLocation.Full() // everything → codeberg.org/haraldrudell/mypackage.(*MyType).MyFunc-/fs/mypackage/myfile.go:19 codeLocation.String() // two lines → "codeberg.org/haraldrudell/mypackage.(*MyType).MyFunc\n /fs/mypackage/myfile.go:19" Stack can determine where a goroutine was created and whether this is the main thread pruntime.GoRoutineID() → 1 pruntime.NewStack(0).Creator.Short() → main.main-pruntime.go:30 fmt.Println(pruntime.NewStack(0).IsMainThread) → true pruntime.NewStack(0).Frames[0].Args → (0x104c12c60?)
|
Package pruntime provides an interface to the Go standard library’s runtime package using only serializable simple types Stack traces and code locations have several formats: codeLocation := pruntime.NewCodeLocation(0) codeLocation.Base() // package and type → mypackage.(*MyType).MyFunc codeLocation.PackFunc() // very brief → mypackage.MyFunc codeLocation.Name(): // function name only → MyFunc codeLocation.Short() // line, no package path → mypackage.(*MyType).MyFunc-myfile.go:19 codeLocation.Long() // uniquely identifiable → codeberg.org/haraldrudell/mypackage.(*MyType).MyFunc-myfile.go:19 codeLocation.Full() // everything → codeberg.org/haraldrudell/mypackage.(*MyType).MyFunc-/fs/mypackage/myfile.go:19 codeLocation.String() // two lines → "codeberg.org/haraldrudell/mypackage.(*MyType).MyFunc\n /fs/mypackage/myfile.go:19" Stack can determine where a goroutine was created and whether this is the main thread pruntime.GoRoutineID() → 1 pruntime.NewStack(0).Creator.Short() → main.main-pruntime.go:30 fmt.Println(pruntime.NewStack(0).IsMainThread) → true pruntime.NewStack(0).Frames[0].Args → (0x104c12c60?) |
Package sqldb interfaces database/sql
|
Package sqldb interfaces database/sql |
pterm
module
|
|
Package parltime provides time utility functions
|
Package parltime provides time utility functions |
sqliter
module
|
|
Package ghandi interfaces Android devices Package ghandi interfaces Android devices Package ghandi interfaces Android devices Package threadprof provide profiling of threading
|
Package ghandi interfaces Android devices Package ghandi interfaces Android devices Package ghandi interfaces Android devices Package threadprof provide profiling of threading |
watchfs
module
|
|
yaml
module
|
|
yamler
module
|