utils

package
v0.0.0-...-6b835ca Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePassword

func ComparePassword(hashPassword []byte, rawPassword []byte) error

ComparePassword bcrypt compare with given hash password and raw password

func FloatToStr

func FloatToStr(aval float64) string

FloatToStr formats float number for text representation. TODO: add formatting options as "#,##0.00"

func HashPassword

func HashPassword(password string, cost int) string

HashPassword bcrypt hash generator with given password string and cost

func InArray

func InArray(val interface{}, array interface{}) (exists bool, index int)

InArray array search with given value

func Int64ToStr

func Int64ToStr(aval int64) string

Int64ToStr is shorthand for strconv.FormatInt with base 10

func JoinInt64Array

func JoinInt64Array(lns []int64, sep string) string

JoinInt64Array int64 array join

func NewFuncMap

func NewFuncMap() map[string]interface{}

NewFuncMap template func generate

func ParseAndExecTemplateFromString

func ParseAndExecTemplateFromString(s string, data interface{}) (string, error)

ParseAndExecTemplateFromString parses string, creates template and exeutes, returns resulting string

func ParseInt

func ParseInt(str string, base int, bitSize int) (i int64, flag bool)

ParseInt string to itneger

func ParseTime

func ParseTime(val string) (time.Time, error)

ParseTime parse string to time

func Passkey

func Passkey() string

Passkey generates a string passkey with an absolute length of 192.

func StrToDate

func StrToDate(aval string) (time.Time, error)

StrToDate string to date

func StrToFloat

func StrToFloat(aval string) float64

StrToFloat is shorhand for strconv.ParseFşoat with bitSize 64, returns 0 if parsing error occurs.

func StrToInt

func StrToInt(aval string) int

StrToInt is shorhant for strconv.Atoi, returns 0 if parsing error occurs.

func StrToInt64

func StrToInt64(aval string) int64

StrToInt64 is shorthand for strconv.ParseInt with base 10, bitSize 64, returns 0 if parsing error occurs.

func StrToTime

func StrToTime(aval string) (time.Time, error)

StrToTime string to time

func StrToTimeStamp

func StrToTimeStamp(aval string) (time.Time, error)

StrToTimeStamp string to timestamp

func StringInSlice

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

StringInSlice string slice search

func ToSnakeCase

func ToSnakeCase(str string) string

ToSnakeCase string convert snake case

func ValidateStruct

func ValidateStruct(r interface{}) (map[string]string, error)

ValidateStruct struct validator

Types

type Logger

type Logger struct {
	zerolog.Logger
}

Logger Custom Logger Structure

func NewLogger

func NewLogger(mode string) *Logger

NewLogger We start custom logger according to our working environment.

func (*Logger) LogDebug

func (l *Logger) LogDebug(msg string)

LogDebug Debug log

func (*Logger) LogError

func (l *Logger) LogError(err error, msg string)

LogError Error log

func (*Logger) LogFatal

func (l *Logger) LogFatal(err error)

LogFatal Fatal log

func (*Logger) LogInfo

func (l *Logger) LogInfo(msg string)

LogInfo Info log

Jump to

Keyboard shortcuts

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