commons

package
v0.0.0-...-315b7b0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeGet    = "get"
	ModePost   = "post"
	ModePut    = "put"
	ModeDelete = "delete"
)

Variables

This section is empty.

Functions

func ComparePasswords

func ComparePasswords(hashedPwd string, plainPwd []byte) bool

func DB64

func DB64(s string) string

DB64 return a decoded string from a base64 string

func DetectContentCharset

func DetectContentCharset(body io.Reader) string

DetectContentCharset try to guess the charset of the given reader

func EB64

func EB64(s string) string

EB64 return an encoded base64 string

func HashAndSalt

func HashAndSalt(password string) (string, error)

func If

func If(condition bool, t interface{}, f interface{}) interface{}

func PrimitiveArrayContains

func PrimitiveArrayContains(array interface{}, element interface{}) int

func ReadLinesOfFile

func ReadLinesOfFile(filename string) ([]string, error)

ReadLinesOfFile open a file and split it into lines

func Reader

func Reader(charset string, input io.Reader) (io.Reader, error)

Reader returns an io.Reader that converts the provided charset to UTF-8.

func SHA1

func SHA1(str string) string

SHA1 hashes a string in SHA1

func Shuffle

func Shuffle(vals []string)

Shuffle randomize the order of a given array

func String2Milliseconds

func String2Milliseconds(t string) int

String2Milliseconds return a timestamp in milliseconds given a humanize time (e.g. 1s, 1h ...)

func TimeInMilliseconds

func TimeInMilliseconds() int64

TimeInMilliseconds return a timestamp in milliseconds

func TimeInNanoseconds

func TimeInNanoseconds() int64

TimeInNanoseconds return a timestamp in nanoseconds

func TimeInSeconds

func TimeInSeconds() int64

TimeInSeconds return a timestamp in seconds

func Try

func Try(body func(), handler func(interface{}))

Try is an attempt to simulate try/catch

func UUID

func UUID() string

UUID() return a random Unique identifier

func YYYYMMDD

func YYYYMMDD() string

YYYYMMDD return a date

func YYYYMMDDHH

func YYYYMMDDHH() string

YYYYMMDDHH return a date with hour granularity

Types

This section is empty.

Jump to

Keyboard shortcuts

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