util

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clamp

func Clamp[T constraints.Integer](v, min, max T) T

func HexStringToBytes

func HexStringToBytes(s string) ([]byte, []bool)

HexStringToBytes converts a hex string to a byte slice. The second return value is a slice of booleans indicating whether each byte was successfully parsed. If a byte could not be parsed, it will be set to 0.

func Max

func Max[T constraints.Integer](a, b T) T

func Min

func Min[T constraints.Integer](a, b T) T

func SwapFile

func SwapFile(a, b string) error

SwapFile swaps the two files. This is done by renaming a to a temporary name, renaming b to a, and renaming the temporary name to b.

In the future this could be made atomic on Linux using the renameat2 syscall.

Types

type Row

type Row struct {
	Key string
	Val string
}

func Inspect

func Inspect(buf []byte, byteOrder binary.ByteOrder) []Row

Inspect returns a list of string representations of the byte slice.

Jump to

Keyboard shortcuts

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