utils

package
v0.0.0-...-5ce5ac0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clamp

func Clamp(val, min, max int64) int64

Clamp ensure the value is within a range

func DoCastF64

func DoCastF64(v any) float64

func DoCastStr

func DoCastStr(v any) string

func DoParseI64

func DoParseI64(v string) (out int64)

func FI64

func FI64[T Ints](v T) string

FI64 formats any int types to string

func GetNbr

func GetNbr(doc *goquery.Document, name string) int64

func GetNbrShips

func GetNbrShips(doc *goquery.Document, name string) int64

func I64Ptr

func I64Ptr(v int64) *int64

I64Ptr returns a pointer to int64

func InArr

func InArr[T comparable](needle T, haystack []T) bool

func InArray

func InArray[T Equalable[T]](needle T, haystack []T) bool

func MaxInt

func MaxInt(vals ...int64) int64

MaxInt returns the minimum int64 value

func MinInt

func MinInt(vals ...int64) int64

MinInt returns the minimum int64 value

func ParseI64

func ParseI64(v string) (out int64, err error)

func ParseInt

func ParseInt(val string) int64

ParseInt ...

func Ptr

func Ptr[T any](v T) *T

Ptr return a pointer to v

func RandChoice

func RandChoice[T any](arr []T) T

RandChoice returns a random element from an array

func RandDuration

func RandDuration(min, max time.Duration) time.Duration

RandDuration generates random duration

func RandFloat

func RandFloat(min, max float64) float64

func RandMs

func RandMs(min, max int64) time.Duration

RandMs generates random duration in milliseconds

func Random

func Random(min, max int64) int64

Random generates a number between min and max inclusively

func ReadBody

func ReadBody(resp *http.Response) (respContent []byte, err error)

func RoundThousandth

func RoundThousandth(n float64) float64

RoundThousandth round value to the nearest thousandth

func Ternary

func Ternary[T any](predicate bool, a, b T) T

func TernaryOrZero

func TernaryOrZero[T any](predicate bool, a T) T

func ToInt

func ToInt(buf []byte) (n int)

Types

type Equalable

type Equalable[T any] interface {
	Equal(other T) bool
}

type Ints

type Ints interface {
	~int64 | ~int
}

Jump to

Keyboard shortcuts

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