Documentation
¶
Overview ¶
Package xlib is an ever growing collection of useful Go functions.
Index ¶
- func CloneSlice[S ~[]T, T any](src S) (res S)
- func FilterIt[T any](src iter.Seq[T], pred func(T) bool) iter.Seq[T]
- func JoinStrings(sep string, args ...string) string
- func MapIt[T, U any](src iter.Seq[T], fn func(T) U) iter.Seq[U]
- func PipeIt[T any](src iter.Seq[T]) iter.Seq[T]
- func WriteByte(w io.Writer, b byte) (err error)
- func WriteFile(pathname string, fn func(*bufio.Writer) error) (err error)
- func WriteRune(w io.Writer, r rune) (err error)
- func WriteString(w io.Writer, s string) (err error)
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 ¶
FilterIt creates a new iterator that filters items from the original iterator using the supplied predicate.
func JoinStrings ¶
JoinStrings is similar to strings.Join, but more comfortable to use in some scenarios.
func MapIt ¶
MapIt creates a new iterator that converts each item from the original iterator via the given function.
func PipeIt ¶
PipeIt creates a new iterator that runs the original iterator in a dedicated goroutine.
func WriteFile ¶
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.