util

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPanic

func CheckPanic()

CheckPanic catches panic.

func FormatInt

func FormatInt[T constraints.Signed](i T) string

func MD5

func MD5(s ...string) string

MD5 computes the MD5 hash of unordered strings.

func NewMatrix32

func NewMatrix32(row, col int) [][]float32

NewMatrix32 creates a 2D matrix of 32-bit floats.

func NewMatrixInt

func NewMatrixInt(row, col int) [][]int

NewMatrixInt creates a 2D matrix of integers.

func NewRand

func NewRand(seed int64) *rand.Rand

NewRand returns a rand.Rand that is threadsafe.

func NewTensor32

func NewTensor32(a, b, c int) [][][]float32

NewTensor32 creates a 3D tensor of 32-bit floats.

func ParseFloat

func ParseFloat[T constraints.Float](s string) (T, error)

func ParseInt

func ParseInt[T constraints.Signed](s string) (T, error)

func ParseUInt

func ParseUInt[T constraints.Unsigned](s string) (T, error)

func RangeInt

func RangeInt(n int) []int

RangeInt generate a slice [0, ..., n-1].

func RepeatFloat32s

func RepeatFloat32s(n int, value float32) []float32

RepeatFloat32s repeats value n times.

func ValidateId

func ValidateId(text string) error

ValidateId validates user/item id. Id cannot be empty and contain [/,].

Types

type RandomGenerator

type RandomGenerator struct {
	*rand.Rand
}

RandomGenerator is the random generator for gorse.

func NewRandomGenerator

func NewRandomGenerator(seed int64) RandomGenerator

NewRandomGenerator creates a RandomGenerator.

func (RandomGenerator) NewNormalVector

func (rng RandomGenerator) NewNormalVector(size int, mean, stdDev float32) []float32

NewNormalVector makes a vec filled with normal random floats.

func (RandomGenerator) NormalMatrix

func (rng RandomGenerator) NormalMatrix(row, col int, mean, stdDev float32) [][]float32

NormalMatrix makes a matrix filled with normal random floats.

func (RandomGenerator) NormalVector

func (rng RandomGenerator) NormalVector(size int, mean, stdDev float32) []float32

func (RandomGenerator) NormalVector64

func (rng RandomGenerator) NormalVector64(size int, mean, stdDev float64) []float64

NormalVector64 makes a vec filled with normal random floats.

func (RandomGenerator) Sample

func (rng RandomGenerator) Sample(low, high, n int, exclude ...mapset.Set[int]) []int

Sample n values between low and high, but not in exclude.

func (RandomGenerator) SampleInt32

func (rng RandomGenerator) SampleInt32(low, high int32, n int, exclude ...mapset.Set[int32]) []int32

SampleInt32 n 32bit values between low and high, but not in exclude.

func (RandomGenerator) UniformMatrix

func (rng RandomGenerator) UniformMatrix(row, col int, low, high float32) [][]float32

UniformMatrix makes a matrix filled with uniform random floats.

func (RandomGenerator) UniformVector

func (rng RandomGenerator) UniformVector(size int, low, high float32) []float32

UniformVector makes a vec filled with uniform random floats,

type TLSConfig

type TLSConfig struct {
	SSLCA   string
	SSLCert string
	SSLKey  string
}

Jump to

Keyboard shortcuts

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