Help us shape the future of Go! Take the 2026 Go Developer Survey

util

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateNetAmount

func CalculateNetAmount(amount int64, discount int16) (int64, error)

func CapitalizeWords added in v1.1.0

func CapitalizeWords(s string) string

CapitalizeWords upper-cases the first letter of each space-separated word and collapses runs of whitespace, so " alex sal" becomes "Alex Sal". The rest of each word is left as typed ("McDonald" stays "McDonald").

func CheckPassword

func CheckPassword(password, hash string) error

func HashPassword

func HashPassword(password string) (string, error)

func RandomAmount

func RandomAmount() int64

func RandomAttributeValue

func RandomAttributeValue() string

func RandomCode

func RandomCode() string

func RandomCurrency

func RandomCurrency() string

func RandomDiscount

func RandomDiscount() int16

func RandomEmail

func RandomEmail() string

func RandomInt

func RandomInt(min, max int64) int64

func RandomLongitudeLatitude

func RandomLongitudeLatitude() sql.NullFloat64

func RandomName

func RandomName() string

func RandomNumber

func RandomNumber() int64

func RandomPhone

func RandomPhone() string

func RandomQuantity

func RandomQuantity() int64

func RandomString

func RandomString(n int) string

Types

type Config

type Config struct {
	DBDriver             string        `mapstructure:"DB_DRIVER"`
	DBSource             string        `mapstructure:"DB_SOURCE"`
	HTTPServerAddress    string        `mapstructure:"HTTP_SERVER_ADDRESS"`
	GRPCServerAddress    string        `mapstructure:"GRPC_SERVER_ADDRESS"`
	GatewayServerAddress string        `mapstructure:"GATEWAY_SERVER_ADDRESS"`
	TokenSymmetricKey    string        `mapstructure:"TOKEN_SYMMETRIC_KEY"`
	AccessTokenDuration  time.Duration `mapstructure:"access_token_duration"`
	RefreshTokenDuration time.Duration `mapstructure:"REFRESH_TOKEN_DURATION"`
	// ExpenseImageStorageDir is where receipt photos uploaded through the
	// one-time QR flow (api/expense_upload.go) are saved on local disk.
	ExpenseImageStorageDir string `mapstructure:"EXPENSE_IMAGE_STORAGE_DIR"`
	// ShiftReceiptImageStorageDir is where close-shift receipt photos
	// forwarded by kashi-pos (api/branch_shift_receipt_image.go) are saved.
	// Defaults to ./storage/shift_receipt_images when unset.
	ShiftReceiptImageStorageDir string `mapstructure:"SHIFT_RECEIPT_IMAGE_STORAGE_DIR"`
	// TransferAttachmentStorageDir is where the optional photo attached to
	// a branch-initiated transfer request (api/branch_transfer.go) is
	// saved. Defaults to ./storage/transfer_attachments when unset.
	TransferAttachmentStorageDir string `mapstructure:"TRANSFER_ATTACHMENT_STORAGE_DIR"`
	// AppReleaseStorageDir is where till app builds published for remote
	// update (api/app_update.go) are saved. Defaults to
	// ./storage/app_releases when unset.
	AppReleaseStorageDir string `mapstructure:"APP_RELEASE_STORAGE_DIR"`
	// GeoIPDir holds the DB-IP lite databases the Security page locates
	// visitors with (api/geoip.go downloads them). Defaults to
	// ./storage/geoip when unset.
	GeoIPDir string `mapstructure:"GEOIP_DIR"`
	// AppLogPath is the bounded, rotating backend log file. It defaults to
	// logs/kashi.log when APP_LOG_PATH is not set.
	AppLogPath string `mapstructure:"APP_LOG_PATH"`
	// ResendAPIKey sends emailed invoice reports (api/email_report.go)
	// through Resend. Unset means email is off on this server.
	ResendAPIKey string `mapstructure:"RESEND_API_KEY"`
}

func LoadConfig

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

type RotatingLogWriter

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

RotatingLogWriter keeps the active log and one backup, bounding total disk usage to roughly 10 MB. Writes are serialized so concurrent HTTP handlers cannot rotate or write the file at the same time.

func ConfigureAppLogging

func ConfigureAppLogging(path string) (*RotatingLogWriter, error)

ConfigureAppLogging retains normal console output and mirrors all standard Go log messages to the bounded rotating file.

func (*RotatingLogWriter) Close

func (writer *RotatingLogWriter) Close() error

func (*RotatingLogWriter) Path

func (writer *RotatingLogWriter) Path() string

func (*RotatingLogWriter) Write

func (writer *RotatingLogWriter) Write(data []byte) (int, error)

Directories

Path Synopsis
Package imageopt turns arbitrary uploaded photos into small, good-looking WebP files.
Package imageopt turns arbitrary uploaded photos into small, good-looking WebP files.

Jump to

Keyboard shortcuts

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