utils

package
v0.0.0-...-cefa481 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePlaceholder

func CreatePlaceholder(length int) string

Create placeholder string with the input "length" long (e.g. 1 returns $1, 2 returns $1, $2)

func CreateSetConditions

func CreateSetConditions(data []SplitMap) string

Create "SET" conditions string with the input "data" Values are replaced with placeholders (e.g. []SplitMap{{"id", 1}, {"name", "John"}} returns "id = $1, name = $2") NB: To be used together with the MapToStructSlice function

func GetRouteGroup

func GetRouteGroup(r *http.Request) string

func IsValidEmail

func IsValidEmail(email string) bool

func LogJobMessage

func LogJobMessage(format string, args ...interface{})

Logger to be used in the Jobs layer

func LogMessage

func LogMessage(format string, args ...interface{})

func Printer

func Printer() *message

func SliceToMap

func SliceToMap(cols []string, vals []interface{}) map[string]interface{}

func StructSliceToMap

func StructSliceToMap(obj interface{}) []map[string]interface{}

func StructToMap

func StructToMap(obj interface{}) map[string]interface{}

The struct - "obj", fields must have json tags

Types

type RequestError

type RequestError struct {
	Code int
	Err  error
}

func (*RequestError) Error

func (r *RequestError) Error() string

func (*RequestError) StatusCode

func (r *RequestError) StatusCode() int

type SplitMap

type SplitMap struct {
	Key   string
	Value interface{}
}

func MapToStructSlice

func MapToStructSlice(data map[string]interface{}) []SplitMap

Split map[string]interface{} into []SplitMap (e.g map[string]interface{"id": 1, "name": "John"} returns []SplitMap{{"id", 1}, {"name", "John"}})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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