xlib

package module
v0.0.0-...-ed89e1a Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

README

Ever growing collection of useful Go functions.

GoDoc Go Report Card

Project status

Tested on Linux Mint 22.3, requires Go version 1.24 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 CloneSlice

func CloneSlice[S ~[]T, T any](src S) (res S)

Clone returns a shallow copy of the slice. Unlike slices.Clone, the resulting slice has the capacity equal to the number of elements in the source slice.

func FilterIt

func FilterIt[T any](src iter.Seq[T], pred func(T) bool) iter.Seq[T]

FilterIt creates a new iterator that filters items from the original iterator using the supplied predicate.

func JoinStrings

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

JoinStrings is similar to strings.Join, but more comfortable to use in some scenarios.

func MapIt

func MapIt[T, U any](src iter.Seq[T], fn func(T) U) iter.Seq[U]

MapIt creates a new iterator that converts each item from the original iterator via the given function.

func PipeIt

func PipeIt[T any](src iter.Seq[T]) iter.Seq[T]

PipeIt creates a new iterator that runs the original iterator in a dedicated goroutine.

func WriteByte

func WriteByte(w io.Writer, b byte) (err error)

WriteByte writes the given byte to the given io.Writer.

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.

func WriteRune

func WriteRune(w io.Writer, r rune) (err error)

WriteRune writes the given rune to the given io.Writer.

func WriteString

func WriteString(w io.Writer, s string) (err error)

WriteString writes the given string to the given io.Writer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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