util

package
v0.0.0-...-61ffae0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BooleanToInt

func BooleanToInt(val bool) int

func Btoi

func Btoi(b bool) int

func ChunkAnySlice

func ChunkAnySlice[T any](slice []T, chunkSize int) [][]T

func ChunkSlice

func ChunkSlice(slice []int64, chunkSize int) [][]int64

func ChunkSliceStruct

func ChunkSliceStruct[T interface{}](slice []T, chunkSize int) [][]T

func CompareSliceExact

func CompareSliceExact[T comparable](a, b []T) bool

CompareSliceExact compare two slice with equal value and order

func CompareSliceValue

func CompareSliceValue[T comparable](a, b []T) bool

CompareSliceValue compare two slice with equal value but not order

func Contains

func Contains[T comparable](s []T, e T) bool

func ContainsInt64

func ContainsInt64(i []int64, e int64) bool

func ContainsString

func ContainsString(str string, substrs []string) bool

func ConvertPhoneFirstZero

func ConvertPhoneFirstZero(phone string) (string, error)

func CurrencySprint

func CurrencySprint(a interface{}) string

func DateToStringParsing

func DateToStringParsing(inputTime *time.Time) string

func Explode

func Explode(delimiter, text string) []string

func FormatPhoneNumber

func FormatPhoneNumber(phone string) string

func GetMilisecondAddDay

func GetMilisecondAddDay(dayAdd int) int64

func GetMilisecondNow

func GetMilisecondNow() int64

func GetRangeTimeFromNow

func GetRangeTimeFromNow(dayAdd int) (startDateEpoch, endDateEpoch int64)

func HashAndSalt

func HashAndSalt(pwd []byte) (string, error)

func IntToSliceString

func IntToSliceString(value []int) string

func IsSlice

func IsSlice(v interface{}) bool

func Itob

func Itob(i int) bool

func NewValidator

func NewValidator() *mValidator

func ParseToBoolean

func ParseToBoolean(val interface{}) (bool, error)

func ParseToNumber

func ParseToNumber[T float64 | float32 | int64 | int32 | int16 | int8 | int](val interface{}) (T, error)

func ParseToString

func ParseToString(val interface{}) (string, error)

func ParseToStruct

func ParseToStruct(val interface{}, target interface{}) error

func PrecisionRound

func PrecisionRound(num float64, precision int) float64

func SliceToSliceInt

func SliceToSliceInt(value string) ([]int, error)

func SplitStringTimeParsing

func SplitStringTimeParsing(timeString string) (time.Time, error)

func StringDateParsing

func StringDateParsing(dateString string) (time.Time, error)

func StringInSlice

func StringInSlice(a string, list []string) bool

func StringTimeCustomParsing

func StringTimeCustomParsing(timeString, layout string) (time.Time, error)

func StringTimeParsing

func StringTimeParsing(timeString string) (time.Time, error)

func StringToSliceString

func StringToSliceString(value string) []string

func TimeToCustomString

func TimeToCustomString(inputTime time.Time, layout string) string

func TimeToString

func TimeToString(inputTime time.Time, lang language.Tag) string

func TimeToStringHHmm

func TimeToStringHHmm(inputTime time.Time, separator string) string

func TimeToStringHHmmss

func TimeToStringHHmmss(inputTime time.Time, separator string) string

func TimeToStringLocale

func TimeToStringLocale(inputTime time.Time) string

func TimeToStringParsing

func TimeToStringParsing(inputTime time.Time) string

func TimeToStringYYYYmmDD

func TimeToStringYYYYmmDD(inputTime time.Time, separator string) string

Types

type GormLogger

type GormLogger struct {
	SlowThreshold time.Duration
	gormLogger.LogLevel
	Logger *logrus.Logger
}

func NewGormLogger

func NewGormLogger(logger *logrus.Logger, logLevel gormLogger.LogLevel) *GormLogger

func (GormLogger) Error

func (g GormLogger) Error(ctx context.Context, msg string, args ...interface{})

func (GormLogger) Info

func (g GormLogger) Info(ctx context.Context, msg string, args ...interface{})

func (*GormLogger) LogMode

func (g *GormLogger) LogMode(logLevel gormLogger.LogLevel) gormLogger.Interface

func (*GormLogger) SetSlowThreshold

func (g *GormLogger) SetSlowThreshold(d time.Duration)

func (GormLogger) Trace

func (g GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)

func (GormLogger) Warn

func (g GormLogger) Warn(ctx context.Context, msg string, args ...interface{})

type Validator

type Validator interface {
	// Real mengembalian validator instance asli
	Real() *validator.Validate

	// SliceStruct menerima payload []struct dan mengembalikan validasi error yang
	// didapatkan dalam bentuk map string, dan error aslinya. inputan valid apabila err nil
	SliceStruct(input interface{}) (map[string]interface{}, error)

	// SliceStruct menerima payload []struct dan mengembalikan validasi error yang
	// didapatkan dalam bentuk map string dan error aslinya. inputan valid apabila err nil
	Struct(input interface{}) (map[string]interface{}, error)

	// Var menerima payload variable dan mengembalikan validasi error yang
	// didapatkan dalam bentuk map string dan error aslinya. inputan valid apabila err nil
	// eg.
	// var i int
	// validate.Var(i, "gt=1,lt=10")
	Var(input interface{}, tag string) (map[string]interface{}, error)
}

Jump to

Keyboard shortcuts

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