utils

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MDB_TO_GO = reverseLanguages()

Functions

func BindErrorMessage

func BindErrorMessage(err error) string

func Contains added in v1.6.6

func Contains(list []interface{}, elem interface{}) bool

func ConvertArgsInt64

func ConvertArgsInt64(args []int64) []interface{}

func ConvertArgsString

func ConvertArgsString(args []string) []interface{}

func DataStoresMiddleware

func DataStoresMiddleware(mbdDB *sql.DB, esManager, logger, cm interface{}, tc interface{}, cms interface{}, variables interface{}) gin.HandlerFunc

Set MDB, ES & LOGGER etc. clients in context

func DetectLanguage

func DetectLanguage(text string, interfaceLanguage string, acceptLanguage string, uiOrder []string) []string

func ErrorHandlingMiddleware

func ErrorHandlingMiddleware() gin.HandlerFunc

Handle all errors

func Filter added in v1.12.0

func Filter(list []interface{}, test func(interface{}) bool) ([]interface{}, []interface{})

func First added in v1.12.0

func First(list []interface{}, test func(interface{}) bool) interface{}

func GenerateName added in v1.1.7

func GenerateName(n int) string

func GenerateUID added in v1.1.7

func GenerateUID(n int) string

func GroupBy added in v1.12.0

func GroupBy(list []interface{}, value func(interface{}) interface{}) map[interface{}][]interface{}

func HasNumeric added in v1.12.0

func HasNumeric(term string) (bool, bool)

Return values: 1. Whole term is numeric. 2. At least part of the term is numeric.

func InitConfig

func InitConfig(cfgFile string, cfgPath string) error

func Int64InSlice added in v0.6.9

func Int64InSlice(i int64, s []int64) bool

func IntersectSortedStringSlices added in v1.4.4

func IntersectSortedStringSlices(first []string, second []string) []string

func Is added in v1.6.6

func Is(slice interface{}) []interface{}

func IsEmpty

func IsEmpty(s []string) bool

true if every string in given slice is empty

func Join added in v0.7.8

func Join(l []interface{}, separator string) string

func JoinErrors added in v1.3.3

func JoinErrors(one error, two error) error

Joins two errors to one.

func JoinErrorsWrap added in v1.3.4

func JoinErrorsWrap(one error, two error, twoErrorMessage string) error

func LogError added in v0.9.0

func LogError(err error)

func LogRequestError added in v0.9.0

func LogRequestError(r *http.Request, err error)

func LoggerMiddleware added in v0.7.8

func LoggerMiddleware() gin.HandlerFunc

func MaxByValue added in v1.12.0

func MaxByValue(list []interface{}, value func(interface{}) float64) interface{}

func MaxInt added in v1.1.1

func MaxInt(x, y int) int

Like math.Max for int

func Min

func Min(x, y int) int

Like math.Min for int

func MinInt added in v1.2.4

func MinInt(x, y int) int

Like math.Min for int

func MinMax added in v1.6.6

func MinMax(x, y int) (int, int)

func Must

func Must(err error)

panic if err != nil

func NumberInHebrew added in v1.6.8

func NumberInHebrew(n int) string

func Pprint added in v0.7.1

func Pprint(l interface{}) string

func PrintMap added in v0.7.8

func PrintMap(m interface{}) (string, error)

func RecoveryMiddleware

func RecoveryMiddleware() gin.HandlerFunc

Recover with error

func ResolveHost added in v0.9.7

func ResolveHost(c *gin.Context) (host string)

func ResolveScheme added in v0.9.7

func ResolveScheme(c *gin.Context) string

func Select added in v1.12.0

func Select(list []interface{}, newValue func(interface{}) interface{}) []interface{}

func StringMapOrderedKeys added in v1.5.0

func StringMapOrderedKeys(m interface{}) []string

func SumAndMax added in v1.6.3

func SumAndMax(values []int) (int, int)

func ValidationErrorMessage

func ValidationErrorMessage(e *validator.FieldError) string

Types

type Date

type Date struct {
	time.Time
}

A time.Time like structure with date part only JSON marshalling

func (*Date) MarshalJSON

func (d *Date) MarshalJSON() ([]byte, error)

func (*Date) Scan

func (d *Date) Scan(value interface{}) error

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(b []byte) error

type TestDBManager added in v1.1.7

type TestDBManager struct {
	DB *sql.DB
	// contains filtered or unexported fields
}

func (*TestDBManager) DestroyTestDB added in v1.1.7

func (m *TestDBManager) DestroyTestDB() error

func (*TestDBManager) InitTestDB added in v1.1.7

func (m *TestDBManager) InitTestDB() error

Jump to

Keyboard shortcuts

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