helper

package
v2.39.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: CC0-1.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotifInfoType  = "info"
	NotifWarnType  = "warn"
	NotifErrorType = "error"
)

Variables

This section is empty.

Functions

func CheckFolder

func CheckFolder(folderPath string)

func ConstructColNameAndValue

func ConstructColNameAndValue(ctx context.Context, structName interface{}, isNullStruct ...bool) ([]string, []interface{})

func ConstructColNameAndValueBulk

func ConstructColNameAndValueBulk(ctx context.Context, arrayOfData interface{}, conditions ...map[string][]interface{}) (*database.CUDConstructData, error)

func ConstructColNameAndValueForUpdate

func ConstructColNameAndValueForUpdate(ctx context.Context, structName interface{}, anotherValues ...interface{}) *database.CUDConstructData

func ConvertStructToMap added in v2.16.0

func ConvertStructToMap(structSource interface{}) map[string]interface{}

func GenerateJWTToken

func GenerateJWTToken(data interface{}, expireTime ...time.Duration) (string, error)

func GeneratePublicKey added in v2.38.0

func GeneratePublicKey(apiKey string) string

GeneratePublicKey generates a public representation of a decrypted API key This is safe to store on the client side (encrypted or hashed)

func GenerateRandomString

func GenerateRandomString(length int) string

func GenerateRandomStringWithCharset

func GenerateRandomStringWithCharset(length int, charset string) string

func GenerateSelectCols

func GenerateSelectCols(ctx context.Context, source interface{}, opts ...GenSelectColsOptions) []string

func GenerateUUID

func GenerateUUID() string

func GenerateUUIDV4

func GenerateUUIDV4() string

func GetColorUniform

func GetColorUniform(hexColor string) *image.Uniform

func GetFilePath

func GetFilePath() string

func GetFolderAndFileName

func GetFolderAndFileName(path string) (folderPath string, fileName string)

func GetFolderNameWithoutTmp

func GetFolderNameWithoutTmp(path string) (folderName string)

func GetTemplate

func GetTemplate(file string, args, destStruct interface{}) error

func GetTemplateFS

func GetTemplateFS(embedFS embed.FS, file string, args, destStruct interface{}) error

func GetTmpFolderPath

func GetTmpFolderPath() (string, error)

func ParseFileTemplate

func ParseFileTemplate(filePath string, args interface{}, additionalBodyContent ...string) (strings.Builder, error)

func ParseHexColor

func ParseHexColor(s string) (c color.RGBA, err error)

func ParseTemplate

func ParseTemplate(embedFS embed.FS, file string, args interface{}, additionalBodyContent ...string) (strings.Builder, error)

func ParseTemplateFromPath added in v2.35.0

func ParseTemplateFromPath(filePath string, data any, optionalParams ...any) (strings.Builder, error)

func Remove added in v2.3.12

func Remove(slice []interface{}, s int) []interface{}

func SendSlackNotification added in v2.7.0

func SendSlackNotification(ctx context.Context, options ...SentNotifParamOptions) error

func SliceContains added in v2.3.12

func SliceContains(s []string, str string) bool

func ToCamelCase

func ToCamelCase(str string) string

ToCamelCase - will be convert string to camel case format

example:"AnyKind of_string"
result:"AnyKindOfString"

func ToLowerCamelCase

func ToLowerCamelCase(str string) string

ToLowerCamelCase - will be convert string to camel case format with lower case at first letter

example:"AnyKind of_string"
result:"anyKindOfString"

func ToSnakeCase

func ToSnakeCase(s string) string

ToSnakeCase - will be convert string to snake case format

example:"AnyKind of_string"
result:"any_kind_of_string"

func TrimDuplicatedSpace

func TrimDuplicatedSpace(str string) string

func UploadToTmp

func UploadToTmp(ctx context.Context, path *string, file multipart.File, cloudStorage ...*CloudStorageTmpUpload) error

func VerifyAPIKey added in v2.38.0

func VerifyAPIKey(apiKey string, publicKey string) bool

VerifyAPIKey verifies if a decrypted API key matches a public key

Types

type CloudStorageTmpUpload

type CloudStorageTmpUpload struct {
	Storage       storage.Buckets
	TmpBucketName string
}

type CryptoManager added in v2.38.0

type CryptoManager struct {
	// contains filtered or unexported fields
}

CryptoManager handles encryption and decryption of API keys

func NewCryptoManager added in v2.38.0

func NewCryptoManager(encryptionKey string) (*CryptoManager, error)

NewCryptoManager creates a new crypto manager from an encryption key The key should be 32 bytes (256 bits) for AES-256

func NewCryptoManagerFromEnv added in v2.38.0

func NewCryptoManagerFromEnv(envVarName string) (*CryptoManager, error)

NewCryptoManagerFromEnv creates a CryptoManager from an environment variable

func (*CryptoManager) Decrypt added in v2.38.0

func (cm *CryptoManager) Decrypt(encryptedText string) (string, error)

Decrypt decrypts a base64-encoded ciphertext and returns the plaintext

func (*CryptoManager) Encrypt added in v2.38.0

func (cm *CryptoManager) Encrypt(plaintext string) (string, error)

Encrypt encrypts a plaintext API key and returns a base64-encoded ciphertext

type GenSelectColsOptionalParams added in v2.5.3

type GenSelectColsOptionalParams struct {
	// contains filtered or unexported fields
}

type GenSelectColsOptions added in v2.5.3

type GenSelectColsOptions func(*GenSelectColsOptionalParams)

func WithExcludedCols added in v2.5.3

func WithExcludedCols(excludedCols string) GenSelectColsOptions

func WithIncludedCols added in v2.5.3

func WithIncludedCols(includedCols string) GenSelectColsOptions

func WithIsEmbeddedStruct added in v2.21.0

func WithIsEmbeddedStruct(isEmbeddedStruct bool) GenSelectColsOptions

type SentNotifParamOptions added in v2.7.0

type SentNotifParamOptions func(param *sentNotifParam)

func NotifChannel added in v2.7.0

func NotifChannel(channel string) SentNotifParamOptions

func NotifData added in v2.7.0

func NotifData(data map[string]string) SentNotifParamOptions

func NotifMsgType added in v2.7.0

func NotifMsgType(msgType string) SentNotifParamOptions

func NotifTitle added in v2.7.0

func NotifTitle(title string) SentNotifParamOptions

Jump to

Keyboard shortcuts

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