util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DobFormatLayout = "2006-01-02"

Variables

View Source
var Region = os.Getenv("SSM_PS_RG")

Functions

func APICall

func APICall(method, path string, requestBody PropertyMap,
	headers map[string]string) (responseCode int, responseBody map[string]string, err error)

APICall will call api specifed in the path with parameters specified..

func CreateUUID

func CreateUUID() string

CreateUUID create a v4 UUID string without any "-" (hyphen)

func GetConfigValue

func GetConfigValue(key string) string

GetConfigValue get the environment value using the key. if not found, then fetches it from AWS Parameter Store

func GetNestedKeyValue

func GetNestedKeyValue(keys []string, nestedObject interface{}) (value interface{}, found bool)

GetNestedKeyValue will return a nested value using arrays of keys which constitute the path to the nested path eg. for nested key, "top/middle/end" => ["top", "middle", "end"] should be passed as keys if at any stage a key is not found, it returns empty interface and found as false

NOTE: Its the user responsibility to check if found is true, before using interface value

func LeftPad

func LeftPad(data, padding string, totalLength int) string

LeftPad prepends the data with the padding value until the total length is reached

func MapToStruct

func MapToStruct(sourceMap map[string]interface{}, targetStruct interface{}) error

MapToStruct Convert Map to Specified Struct

func ParseDateStr

func ParseDateStr(dateString string) (time.Time, error)

ParseDateStr Convert Date String (YYYY-MM-DD) to time.Time object

func RightPad

func RightPad(data, padding string, totalLength int) string

RightPad appends the data with the padding value until the total length is reached

func StrToHex

func StrToHex(data string, mod int) string

StrToHex converts the data string into multiples of mod bits and prepends the start index of data

Types

type BaseModel

type BaseModel struct {
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `sql:"index" json:"deleted_at,omitempty"`
}

type PropertyMap

type PropertyMap map[string]interface{}

PropertyMap can be used for any non-fixed json to map parsing

func (*PropertyMap) Scan

func (pm *PropertyMap) Scan(src interface{}) error

func (PropertyMap) Value

func (pm PropertyMap) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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