utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintfStdErr

func PrintfStdErr(format string, a ...any)

func PrintlnStdErr

func PrintlnStdErr(a ...any)

func ReplaceAnySchemeWithHttp

func ReplaceAnySchemeWithHttp(endpoint string) string

Types

type FuncUponAppExit added in v1.0.3

type FuncUponAppExit func()

FuncUponAppExit is a function that will be executed upon app exit. Panics will be ignored.

type IAppExitHelper added in v1.0.3

type IAppExitHelper interface {
	// RegisterFuncUponAppExit registers a function to be executed upon app exit.
	RegisterFuncUponAppExit(funcUponAppExit FuncUponAppExit)

	// ExecuteFunctionsUponAppExit executes all registered functions (LIFO) upon app exit.
	// Panics will be ignored and methods will be executed only once.
	ExecuteFunctionsUponAppExit()
}

IAppExitHelper is a helper to register and execute functions upon app exit.

var AppExitHelper IAppExitHelper = &appExitHelper{
	mutex:                        &sync.Mutex{},
	executedFunctionsUponAppExit: false,
	funcUponAppExit:              nil,
}

AppExitHelper is a helper to register and execute functions upon app exit.

type IStdHelper added in v1.1.0

type IStdHelper interface {
	// Println prints a message to stdout or queue message if queue is enabled.
	Println(message any)

	// PrintlnStdErr prints a message to stderr or queue message if queue is enabled.
	PrintlnStdErr(message any)

	// EnableQueue enables queue.
	EnableQueue()

	// PrintQueuedMessages prints queued messages.
	PrintQueuedMessages()
}

IStdHelper is a helper to print stdout & stderr with ability to enable queue messages then will print them out when requested by PrintQueuedMessages().

var StdHelper IStdHelper = &stdHelper{
	mutex:          &sync.RWMutex{},
	queuedMessages: nil,
}

StdHelper implements IStdHelper, to be used to queue messages during T-UI active, then print them out when T-UI is closed. This is to work around the issue that T-UI will clear the screen and error messages will be lost.

Jump to

Keyboard shortcuts

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