util

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: AGPL-3.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUint64

func AddUint64(ns ...uint64) (sum uint64, overflow bool, err error)

AddUint64 adds a list of uint64s together, returning an error and a boolean indicator if the sum overflows uint64.

func BytesToUint32

func BytesToUint32(b []byte) uint32

func BytesToUint64

func BytesToUint64(b []byte) uint64

func FileExists

func FileExists(path string) bool

func IsValidURI

func IsValidURI(u string) bool

func ReadJsonFile

func ReadJsonFile[T any](path string, res *T) (*T, error)

func ShuffleSliceCopy

func ShuffleSliceCopy[T any](src []T) []T

func Uint32ToBytes

func Uint32ToBytes(i uint32) []byte

func Uint64ToBytes

func Uint64ToBytes(i uint64) []byte

func WriteJsonFile

func WriteJsonFile[T any](path string, obj *T) error

Types

type Stack

type Stack[T any] []T

A simple stack implementation. Not thread safe.

func (*Stack[T]) IsEmpty

func (s *Stack[T]) IsEmpty() bool

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() T

Pop pops an item from the stack and panics if the stack is empty. IsEmpty method can be used to check if the following Pop would be successful.

func (*Stack[T]) Push

func (s *Stack[T]) Push(item T)

Jump to

Keyboard shortcuts

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