sys

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBoolEnv

func GetBoolEnv(key string, fallback bool) bool

GetBoolEnv parses a boolean environment variable by the given key, if env is empty, returns the given fallback value

func GetDurationEnv

func GetDurationEnv(key string, fallback time.Duration) time.Duration

GetDurationEnv parses a duration environment variable by the given key, if env is empty, returns the given fallback value

func GetStringEnv

func GetStringEnv(key, fallback string) string

GetStringEnv returns an environment variable by the given key, if env is empty, returns the given fallback value

func RegisterInterruptHandler

func RegisterInterruptHandler(cancelApp context.CancelFunc, eventFn func())

RegisterInterruptHandler registers a handler of interrupt signals from the OS. When signal os.Interrupt is coming, it informs the user about it and calls func `cancelApp`.

func RegisterSignalHandler

func RegisterSignalHandler(cancel context.CancelFunc, sigs ...os.Signal)

RegisterSignalHandler registers a handler of signals from the OS. Before using it you have to ensure a exit from each loop when <-ctx.Done() is releasing Example:

func HelloWorld(ctx context.Context) {
	for {
		select {
		case <-ctx.Done():
			return
		default:
		}
		.....
	}
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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