std

package
v5.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package std provides tools for standard types (strings, int, floats, etc).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone[T any](input T) T

func CloneMap

func CloneMap[M ~map[K]V, K comparable, V any](m M) M

Clone returns a copy of m. This is a shallow clone: the new keys and values are set using ordinary assignment.

func CloneSlice

func CloneSlice[S ~[]E, E any](s S) S

Clone returns a copy of the slice. The elements are copied using assignment, so this is a shallow clone.

func CommonPrefixLen

func CommonPrefixLen[T bytesec](a T, b T) int

func CryptoRandKey

func CryptoRandKey(n int) (string, error)

CryptoRandKey generates a cryptographically secure random string of length n. It uses base64 encoding to represent the random bytes.

func DeepClone

func DeepClone[T any](t T) (dst T)

func DiffSlices

func DiffSlices[S ~[]E, E comparable](prev S, next S) (added S, removed S)

DiffSlices finds added and removed values between previous and next

func FormatPath

func FormatPath(ii ...interface{}) string

func HasImageExtension added in v5.0.3

func HasImageExtension(s string) bool

func ParseCellsDuration

func ParseCellsDuration(s string) (time.Duration, error)

ParseCellsDuration wraps standard time.ParseDuration supporting the "d" unit (as day)

func Randkey

func Randkey(n int) string

Randkey produces a random string with a given length

func Retry

func Retry(ctx context.Context, f func() error, seconds ...time.Duration) error

Retry function

func StringToKeys

func StringToKeys(s ...string) []string

func TopologicalSort

func TopologicalSort[T nameable](objects []TopologicalObject[T]) ([]T, error)

func Unique

func Unique[V comparable, T []V](input T) T

Types

type Cloneable

type Cloneable[T any] interface {
	Clone() T
}

type TopologicalObject

type TopologicalObject[T nameable] struct {
	Object T
	After  []string
}

Jump to

Keyboard shortcuts

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