util

package
v0.0.0-...-b755a7c Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicUpdateMaxUint32

func AtomicUpdateMaxUint32(store *atomic.Uint32, newValue uint32)

AtomicUpdateMaxUint32 updates the value in store using atomic memory primitives. newValue will only be placed in store if newValue is larger than the current value in store. To avoid inconsistency parallel updates to store should be avoided.

func DecToUint64

func DecToUint64(str string) uint64

DecToUint64 is a convenience function to extract a decimal string to a uint64 and not worry about errors. Essentially a "mustConvertDecToUint64".

func HexToUint64

func HexToUint64(str string) uint64

HexToUint64 is a convenience function to extract a hex string to a uint64 and not worry about errors. Essentially a "mustConvertHexToUint64".

func IsValidString

func IsValidString(s string) bool

IsValidString checks if string is UTF-8-encoded and only contains expected characters.

func NextPowerOfTwo

func NextPowerOfTwo(v uint32) uint32

NextPowerOfTwo returns input value if it's a power of two, otherwise it returns the next power of two.

func VersionUint

func VersionUint(major, minor, patch uint32) uint32

VersionUint returns a single integer composed of major, minor, patch.

Types

type OnDiskFileIdentifier

type OnDiskFileIdentifier struct {
	DeviceID uint64 // dev_t as reported by stat.
	InodeNum uint64 // ino_t should fit into 64 bits
}

OnDiskFileIdentifier can be used as unique identifier for a file. It is a structure to identify a particular file on disk by deviceID and inode number.

func (OnDiskFileIdentifier) Hash32

func (odfi OnDiskFileIdentifier) Hash32() uint32

type Range

type Range struct {
	Start uint64
	End   uint64
}

Range describes a range with Start and End values.

Jump to

Keyboard shortcuts

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