util

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package util contains utilities for application.

Index

Constants

This section is empty.

Variables

View Source
var Exit = func(logrusInstance *logrus.Entry, msg string) {
	println("Fatal error, see log file")
	if logrusInstance != nil {
		logrusInstance.Fatalf(msg)
	} else {
		logrus.Fatal(msg)
	}
}

Exit logs exit message to log and calls os.exit. This function can be overridden for testing purposes. LogrusInstance allows overriding default instance to pass additional arguments e.g. with logrus.WithField. It can also be set to nil.

Functions

func DumpGoroutines added in v0.7.0

func DumpGoroutines() error

DumpGoroutines dumps all goroutines into a file in same directory as log file, with timestamped name.

func KeyBindingName

func KeyBindingName(key tcell.Key) string

ShortCutName returns name for given key

func OpenUrlInBrowser added in v0.5.0

func OpenUrlInBrowser(url string) error

OpenUrlInBrowser attempts to open given url in default browser

func PackKeyBindingName

func PackKeyBindingName(key tcell.Key, maxLength int) string

PackKeyBindingName returns shorter for given key Maxlength controls maximum length for text. If 0, disable limiting 'F6' -> F6 'Ctrl+Space' -> 'C-sp'

func RandomKey added in v0.8.0

func RandomKey(length int) string

func SecToString

func SecToString(sec int) string

Print seconds as formatted time: 50, 1:50, 0:05, 1.05, 1:05:05

func SecToStringApproximate

func SecToStringApproximate(sec int) string

SecToStringApproximate gives more verbal output for time duration 1:50 -> 2 min 10:50 -> 11 min 1:11:50 -> 1.1 h

Types

This section is empty.

Jump to

Keyboard shortcuts

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