xlib

package module
v0.0.0-...-86262a9 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

README

Ever growing collection of useful Go functions.

GoDoc Go Report Card

Project status

Tested on Linux Mint 21.1, requires Go version 1.19 or higher.

Documentation

Overview

Package xlib is an ever growing collection of useful Go functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parallel

func Parallel(tasks ...func() error) <-chan error

Parallel starts the given functions each in a separate goroutine, and returns a channel where errors from the functions are posted. The channel is closed when all goroutines have completed.

func StrJoin

func StrJoin(sep string, args ...string) string

StrJoin is similar to strings.Join(), but more comfortable to use in some scenarios.

func StrJoinEx

func StrJoinEx(sep [3]string, args ...string) string

StrJoinEx joins the given arguments using the supplied separators, for example, given the separator list of [": ", ", ", ", and "] and the arguments ["AAA", "BBB", "CCC", "DDD"], the resulting string will be "AAA: BBB, CCC, and DDD".

func WriteFile

func WriteFile(pathname string, fn func(*bufio.Writer) error) (err error)

WriteFile safely replaces the content of the given file. First, it creates a temporary file, then it calls the supplied function to actually write to the file, and in the end it moves the temporary to the given target file. In case of any error or a panic the temporary file is always removed. The target pathname must either not exist, or refer to an existing regular file, in which case it will be replaced. To avoid copying files across different filesystems the temporary file is created in the same directory as the target.

Types

This section is empty.

Jump to

Keyboard shortcuts

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