Documentation
¶
Index ¶
- func AddUint64(ns ...uint64) (uint64, bool)
- func BytesToUint32(b []byte) uint32
- func BytesToUint64(b []byte) uint64
- func FileExists(path string) bool
- func IsValidURI(u string) bool
- func ReadJsonFile[T any](path string, res *T) (*T, error)
- func SafeAdd(a, b uint64) (uint64, bool)
- func SafeSub(a, b uint64) (uint64, bool)
- func ShuffleSliceCopy[T any](src []T) []T
- func TransformSlice[S ~[]E, E any, V any](s S, mapper func(E) V) []V
- func Uint32ToBytes(i uint32) []byte
- func Uint64ToBytes(i uint64) []byte
- func WriteJsonFile[T any](path string, obj T) error
- type Stack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddUint64 ¶
AddUint64 adds a list of uint64s together, returning sum and a boolean indicator if the sum is ok (ie didn't overflow).
Special cases:
- if the list is empty the sum is zero and ok == true;
- if there is just one element in the argument slice it's value will be returned as sum (and ok == true);
Use SafeAdd to add just two ints.
func BytesToUint32 ¶
func BytesToUint64 ¶
func FileExists ¶
func IsValidURI ¶
func ReadJsonFile ¶
func SafeAdd ¶
SafeAdd returns a+b and checks for overflow, the second return value is "ok", ie it is "true" when the returned sum is valid and "false" in case of overflow.
func ShuffleSliceCopy ¶
func ShuffleSliceCopy[T any](src []T) []T
func TransformSlice ¶
TransformSlice processes input slice s by calling the mapper callback for each element and returning the slice of values returned by the callback.
Could be used for extracting single field values from slice of structs etc.
func Uint32ToBytes ¶
func Uint64ToBytes ¶
func WriteJsonFile ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.