misc

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DateFormat = "2006-01-02"
View Source
const TimeFormat = "2006-01-02_15:04:05.000"
View Source
const TimeFormatNoMs = "2006-01-02_15:04:05" // for parsing

Variables

View Source
var TestMessageChannel chan string // If defined, Message writes to this channel
View Source
var TestPromptChannel chan string // If defined, Prompt reads from this channel

Functions

func DoConcurrently

func DoConcurrently[T any, errorT any](
	work func(c chan T, errorChan chan errorT),
	handleError func(e errorT),
	c chan T,
	numWorkers int,
)

DoConcurrently is a simple worker pool implementation. It starts up numWorkers goroutines and, in each, calls `work(c, errorChan)`. Any errors that `work` writes to errorChan are passed to handleError(). DoConcurrently returns when all the workers have exited.

func FormatTime

func FormatTime(t time.Time) string

func Message

func Message(format string, args ...any)

Message prepends the program name and appends a newline to whatever message is passed in, then writes it standard output.

func Prompt

func Prompt(prompt string) bool

Prompt asks a yes/no question. It appends ` y/n ` to the prompt.

func RemovePrefix

func RemovePrefix(key string, prefix string) string

RemovePrefix removes prefix/ from the beginning of a key that is known to start with prefix/.

func SortedKeys

func SortedKeys[T any](m map[string]T) []string

Types

This section is empty.

Jump to

Keyboard shortcuts

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