util

package
v0.5.11 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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) 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

NormalVector makes a vec filled with normal random floats.

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