utils

package
v0.0.0-...-e71a76f Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmptyValue

func EmptyValue(s *string) bool

EmptyValue checks if a string pointer is nil or empty

func GenerateSalt

func GenerateSalt() string

GenerateSalt generates the salt that can be used when hashing a password

func GetPage

func GetPage[T any](list []T, pageSize, page int) []T

GetPage returns a page of a list If pageSize is 0, the whole list is returned

func HashString

func HashString(token string) string

HashString hashes a string using sha256 and returns the base64 encoded string

func HashStringAlphanumeric

func HashStringAlphanumeric(token string) string

HashStringAlphanumeric hashes a string using sha256 and returns the base64 encoded string It also removes the characters that are not allowed in a alphanumeric string

func HashStringAlphanumericLower

func HashStringAlphanumericLower(token string) string

HashStringAlphanumericLower is a lowercase version of HashStringAlphanumeric

func HashStringRfc1123

func HashStringRfc1123(token string) string

HashStringRfc1123 hashes a string using sha256 and returns the base64 encoded string It also removes the characters that are not allowed in a RFC1123 string

func Int64Ptr

func Int64Ptr(i int64) *int64

Int64Ptr converts an int64 to a pointer

func NonZeroOrNil

func NonZeroOrNil(t time.Time) *time.Time

NonZeroOrNil returns a pointer to a time.Time if the time is not zero, otherwise it returns nil

func PrettyPrintError

func PrettyPrintError(err error)

PrettyPrintError prints an error in a pretty way It splits on `details: ` and adds `due to: \n`

func PtrOf

func PtrOf[T any](v T) *T

PtrOf converts a value to a pointer

func StrPtr

func StrPtr(s string) *string

StrPtr converts a string to a pointer

func WithoutNils

func WithoutNils[T any](slice []*T) []T

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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