util

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RMB = "RMB"
	USD = "USD"
	EUR = "EUR"
	CAD = "CAD"
)
View Source
const (
	Visitor = "visitor"
	Admin   = "admin"
)

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(password string, hashedPassword string) error

CheckPassword checks if the provided password is correct or not

func DownloadFile

func DownloadFile(client *resty.Client, url, dst string) error

DownloadFile 从 URL 下载文件并保存到本地

func DownloadFiles

func DownloadFiles(urls []string, dstDir string) error

DownloadFiles 批量下载文件并保存到指定目录

func ExtractFileNames

func ExtractFileNames(content string) []string

func HashPassword

func HashPassword(password string) (string, error)

HashPassword returns the bcrypt hash of the password

func IsSupportedCurrency

func IsSupportedCurrency(currency string) bool

func ListFiles

func ListFiles(dirPath string) ([]string, error)

func RandUserID

func RandUserID() uuid.UUID

func RandomContext

func RandomContext() string

func RandomCurrency

func RandomCurrency() string

RandomCurrency generates a random currency code

func RandomEmail

func RandomEmail() string

RandomEmail generates a random email

func RandomInt

func RandomInt(min, max int64) int64

RandomInt generates a random integer between min an max

func RandomMoney

func RandomMoney() int64

RandomMoney generates a random amount of money

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 RandomSummary

func RandomSummary() string

func RandomTitle

func RandomTitle() string

Types

type Config

type Config struct {
	Environment           string        `mapstructure:"ENVIRONMENT"`
	AllowedOrigins        []string      `mapstructure:"ALLOWED_ORIGINS"`
	DBDriver              string        `mapstructure:"DB_DRIVER"`
	DBUser                string        `mapstructure:"DB_USER"`
	DBPassword            string        `mapstructure:"DB_PASSWORD"`
	DBSource              string        `mapstructure:"DB_SOURCE"`
	MigrationURL          string        `mapstructure:"MIGRATION_URL"`
	ResourcePath          string        `mapstructure:"RESOURCE_PATH"`
	Domain                string        `mapstructure:"DOMAIN"`
	RedisAddress          string        `mapstructure:"REDIS_ADDRESS"`
	HTTPServerAddress     string        `mapstructure:"HTTP_SERVER_ADDRESS"`
	GrpcGatewayAddress    string        `mapstructure:"GRPC_GATEWAY_ADDRESS"`
	GRPCServerAddress     string        `mapstructure:"GRPC_SERVER_ADDRESS"`
	TokenSymmetricKey     string        `mapstructure:"TOKEN_SYMMETRIC_KEY"`
	AccessTokenDuration   time.Duration `mapstructure:"ACCESS_TOKEN_DURATION"`
	RefreshTokenDuration  time.Duration `mapstructure:"REFRESH_TOKEN_DURATION"`
	EmailSenderName       string        `mapstructure:"EMAIL_SENDER_NAME"`
	EmailSenderAddress    string        `mapstructure:"EMAIL_SENDER_ADDRESS"`
	EmailSenderPassword   string        `mapstructure:"EMAIL_SENDER_PASSWORD"`
	UploadFileSizeLimit   int64         `mapstructure:"UPLOAD_FILE_SIZE_LIMIT"`
	UploadFileAllowedMime []string      `mapstructure:"UPLOAD_FILE_ALLOWED_MIME"`
	HTTPProxyAddr         string        `mapstructure:"HTTP_PROXY_ADDR"`
	DefaultUserID         string        `mapstructure:"DEFAULT_USER_ID"`
	DefaultUsername       string        `mapstructure:"DEFAULT_USERNAME"`
	DefaultUserPassword   string        `mapstructure:"DEFAULT_USER_PASSWORD"`
	DefaultUserFullname   string        `mapstructure:"DEFAULT_USER_FULLNAME"`
	DefaultUserEmail      string        `mapstructure:"DEFAULT_USER_EMAIL"`
}

func LoadConfig

func LoadConfig(path string) (config Config, err error)

Jump to

Keyboard shortcuts

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