functions

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(list any, elements ...any) ([]any, error)

Append appends elements to list when list is a slice or array.

func DecodeBase64

func DecodeBase64(input string) (string, error)

DecodeBase64 decodes a Base64-encoded string and returns the original value.

func EncodeBase64

func EncodeBase64(input string) string

EncodeBase64 encodes the input string to its Base64 representation.

func First

func First(list any) (any, error)

First returns the first element of list or nil when list is empty. It supports slices, arrays, and strings.

func Get

func Get(key string, object map[string]any, defaultValue any) any

Get returns object[key] or defaultValue when the key is missing.

func Keys added in v0.4.0

func Keys(object map[string]any) []any

Keys returns the keys of object as a string slice.

func Last

func Last(list any) (any, error)

Last returns the final element of list or nil when list is empty. It supports slices, arrays, and strings.

func List

func List(elements ...any) []any

List returns the provided elements as a slice of any.

func Now

func Now() string

Now returns the current UTC time formatted as RFC3339.

func Object

func Object(keyAndValues ...any) map[string]any

Object builds a map from alternating key and value arguments.

func Pick

func Pick(object map[string]any, keys ...string) map[string]any

Pick creates a map containing only the specified keys found in object.

func Prepend

func Prepend(list any, elements ...any) ([]any, error)

Prepend inserts elements at the beginning of list when list is a slice or array.

func Quote

func Quote(s any) string

Quote wraps the string representation of the input value in double quotes.

func Replace

func Replace(toChange, toBe, s string) string

Replace substitutes every occurrence of toChange with toBe in s.

func Set

func Set(key string, value any, object map[string]any) map[string]any

Set stores value at key in object and returns object.

func Sha256Sum

func Sha256Sum(input string) string

Sha256Sum returns the SHA-256 digest of input encoded in hexadecimal.

func Sha512Sum

func Sha512Sum(input string) string

Sha512Sum returns the SHA-512 digest of input encoded in hexadecimal.

func Split

func Split(sep, s string) []string

Split splits the input string by the given separator and returns the resulting substrings.

func ToJSON

func ToJSON(v any) string

ToJSON converts a value to its JSON string representation.

func ToLower

func ToLower(s string) string

ToLower converts the input string to lowercase.

func ToUpper

func ToUpper(s string) string

ToUpper converts the input string to uppercase.

func TrimPrefix

func TrimPrefix(prefix, s string) string

TrimPrefix removes prefix from s when present.

func TrimSpace

func TrimSpace(s string) string

TrimSpace removes all leading and trailing whitespace from the input string.

func TrimSuffix

func TrimSuffix(suffix, s string) string

TrimSuffix removes suffix from s when present.

func Truncate

func Truncate(length int, s string) string

Truncate keeps a portion of s based on length. A positive length returns the prefix, a negative length preserves the suffix, and values outside the string bounds leave s unchanged.

func UUIDV4

func UUIDV4() (string, error)

UUIDV4 returns a randomly generated (version 4) UUID string.

func UUIDV6

func UUIDV6() (string, error)

UUIDV6 returns a time-ordered (version 6) UUID string.

func UUIDV7

func UUIDV7() (string, error)

UUIDV7 returns a monotonic (version 7) UUID string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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