helpers

package
v0.0.0-...-d0dd730 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDirIfNotExists

func CreateDirIfNotExists(path string) error

CreateDirIfNotExists creates an directory if it does not exists

func ExistDir

func ExistDir(path string) bool

ExistDir checks if an directory exists

func GetDefaultLog

func GetDefaultLog(servicename string, requestID string) *logrus.Entry

GetDefaultLog returns a default Log Entry to be used

func Has

func Has(b, flag Bits) bool

Has checks is a bit in the mask b is set

func IntInSlice

func IntInSlice(a int, list []int) bool

IntInSlice checks if a int is inside a slice

func MigrateDB

func MigrateDB(db *sql.DB, migrationDir string) error

MigrateDB migrates the database to the specified version migrate must be the only param for the binary only goose params may be attached to it

func ParseFormCollection

func ParseFormCollection(r *http.Request, typeName string) []map[string]string

ParseFormCollection - returns an array of maps e.g.form post Contacts[0][Name] = Alice Contacts[0][City] = Seattle Contacts[1][Name] = Bob Contacts[1][City] = Boston

func RandomString

func RandomString(count int) string

RandomString generates a random string of len count

func ReadConfig

func ReadConfig(cmd *cobra.Command, configName string, localConfigName string, config interface{}) error

ReadConfig reads the config from the file and merges the local file if present config files must be in toml format

func StringInSlice

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

StringInSlice checks if a string is inside a slice

func StringInSliceI

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

StringInSliceI checks if a string is inside a slice (caseinsensitive)

func TimeToString

func TimeToString(t time.Time, lang string) string

TimeToString converts a time to a given language time-string

func ValidateRequestData

func ValidateRequestData(destStruct interface{}, log *logrus.Entry, c *gin.Context) bool

ValidateRequestData validates the request data and writes to the response, if not ok

Types

type Bits

type Bits int64

Bits is the bit type (mask)

const (
	F0 Bits = 1 << iota
	F1
	F2
	F3
	F4
	F5
	F6
	F7
	F8
	F9
	F10
	F11
	F12
	F13
	F14
	F15
)

represents the possible bit positions

func Clear

func Clear(b, flag Bits) Bits

Clear clears a bit in the mask b

func Set

func Set(b, flag Bits) Bits

Set sets a bit in the mask b

func Toggle

func Toggle(b, flag Bits) Bits

Toggle toggles a bit in the mask b

Jump to

Keyboard shortcuts

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