common

package
v0.0.0-...-f9aba1a Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Batch

func Batch[T any](ch <-chan T, size uint32) []T

Batch collects items from a channel into a slice of the specified size. Stops if the channel is closed or empty. Does NOT block if the channel is empty.

func ExtractHostFromUrl

func ExtractHostFromUrl(rawUrl string) (string, error)

ExtractHostFromUrl extracts the hostname from a given URL string. Returns an error if the URL is invalid.

func GenerateRandomString

func GenerateRandomString(n int) (string, error)

GenerateRandomString generates a random string of size n

func GetEnvVarDefault

func GetEnvVarDefault(name string, def string) string

GetEnvVarDefault retrieves the value of the specified environment variable. Returns a default value if the variable is not set.

func IsSubset

func IsSubset[T comparable](subset []T, superset []T) bool

IsSubset checks if all elements of the subset are present in the superset.

func RemoveFrom

func RemoveFrom[T comparable](slice []T, item T) []T

RemoveFrom removes all occurrences of a specified item from a slice.

func SplitName

func SplitName(fullName string) (string, string)

SplitName splits a full name into first and last name. If no last name exists, it returns an empty string.

func UrlIsSecure

func UrlIsSecure(rawUrl string) (bool, error)

UrlIsSecure checks if a given URL uses the HTTPS scheme. Returns an error if the URL is invalid.

Types

type ImageFmt

type ImageFmt string
const (
	JPEG ImageFmt = "jpeg"
	PNG  ImageFmt = "png"
	GIF  ImageFmt = "gif"
)

func ImageFormat

func ImageFormat(b []byte) (ImageFmt, error)

Jump to

Keyboard shortcuts

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