utils

package
v0.0.0-...-d9936ee Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinCost     int = 4
	MaxCost     int = 31
	DefaultCost int = 10
)
View Source
const (
	User  = "user"
	Admin = "admin"
)

Variables

This section is empty.

Functions

func ComparePassword

func ComparePassword(hashedPassword string, password string) (bool, error)

Compare Bcrypt.

func Contains

func Contains[T any](arr []T, x T) bool

func ContainsFunc

func ContainsFunc[T any](arr []T, predicate func(T) bool) bool

func ConvertArStringToArNullUUID

func ConvertArStringToArNullUUID(strings []string) ([]uuid.NullUUID, error)

func ConvertArStringToArUUID

func ConvertArStringToArUUID(strings []string) ([]uuid.UUID, error)

func ConvertArUUIDToArString

func ConvertArUUIDToArString(uuids []uuid.UUID) []string

func FormatInt

func FormatInt(n int32) string

func GenerateRandomBytes

func GenerateRandomBytes(length int) ([]byte, error)

func GenerateRandomHexBytes

func GenerateRandomHexBytes(length int) (string, error)

func GetIP

func GetIP(r *http.Request) string

GetIP helps in getting the IP address from the request

func GetKeyMetadata

func GetKeyMetadata(ctx context.Context, key string) (string, error)

func GetUserAgent

func GetUserAgent(r *http.Request) string

GetUserAgent helps in getting the user agent from the request

func HandleHitCache

func HandleHitCache(model interface{}, redis redis.RedisEngine, key string) error

func HandleInterfaceToArrayString

func HandleInterfaceToArrayString(value interface{}) []string

func HandleNullString

func HandleNullString(value interface{}) string

func HashPassword

func HashPassword(password string, options ...func(*hashOptions)) (string, error)

Hash Bcrypt.

func JsonRawMessageToArrayString

func JsonRawMessageToArrayString(rawJson json.RawMessage) ([]string, error)

func LoadFileEnvOnLocal

func LoadFileEnvOnLocal() error

func MapToProtobufStruct

func MapToProtobufStruct(m map[string]interface{}) (*structpb.Struct, error)

func Mapping

func Mapping(in, out interface{}) error

func OutgoingContext

func OutgoingContext(ctx context.Context) (context.Context, error)

func ProtobufStructToMap

func ProtobufStructToMap(s *structpb.Struct) (map[string]interface{}, error)

func ProtobufStructToStruct

func ProtobufStructToStruct(s *structpb.Struct) (interface{}, error)

func RandomEmail

func RandomEmail() string

RandomEmail generates a random email

func RandomEmailCompany

func RandomEmailCompany() string

RandomEmail generates a random email

func RandomInt

func RandomInt(min, max int64) int64

RandomInt generates a random integer between min and max

func RandomOwner

func RandomOwner() string

RandomOwner generates a random owner name

func RandomString

func RandomString(n int) string

RandomString generates a random string of length n

func RandomUUID

func RandomUUID() uuid.UUID

func RemoveSlice

func RemoveSlice[T comparable](inputSlice *[]T, removeItems ...T) []T

func String

func String(n int32) string

func StringToNullUUID

func StringToNullUUID(uuidString string) (uuid.NullUUID, error)

func StringToNullUUIDNormal

func StringToNullUUIDNormal(uuidString string) uuid.NullUUID

func StringToUUID

func StringToUUID(uuidString string) (uuid.UUID, error)

func StringToUUIDNormal

func StringToUUIDNormal(uuidString string) uuid.UUID

func StructToProtobufStruct

func StructToProtobufStruct(s interface{}) (*structpb.Struct, error)

func ToStruct

func ToStruct(v map[string]interface{}) *st.Struct

ToStruct converts a map[string]interface{} to a ptypes.Struct

func ToValue

func ToValue(v interface{}) *st.Value

ToValue converts an interface{} to a ptypes.Value

func UniqueSlice

func UniqueSlice[T comparable](inputSlice []T) []T

Types

This section is empty.

Jump to

Keyboard shortcuts

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