tools

package
v0.0.0-...-9821454 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	InfoColor    = "\033[1;34m"
	NoticeColor  = "\033[1;36m"
	WarningColor = "\033[1;33m"
	ErrorColor   = "\033[1;31m"
	DebugColor   = "\033[0;36m"
)

colors for terminal ouput

View Source
const (
	ProrataStrict       = 0
	ProrataEndOfMonth   = 1
	ProrataBeginOfMonth = 2
	ProrataBoth         = 3
)

constants to interpret month prorata calculation

Variables

This section is empty.

Functions

func ConvertAmountToString

func ConvertAmountToString(a int64, decimalSep string) string

ConvertAmountToString function converts a amount of CENTS into a real string

func ConvertStringToAmount

func ConvertStringToAmount(s string, decimalSep string, thousandSep string) (int64, error)

ConvertStringToAmount function converts a string amount into an int64 of CENTS. we use that trick to avoid any float in the app (and rounding issues) " - 1234,43 " --> -123443 "0" --> 0 "345 " --> 34500 " 345,1" --> 3451 "- 0,00" --> 0 "345," --> 3450

func DebugPrintf

func DebugPrintf(format string, a ...interface{}) (n int, err error)

DebugPrintf print a debug txt

func DownloadFromS3

func DownloadFromS3(bucketName string, itemName string) (string, error)

DownloadFromS3 will get the file from the given bucket and path and will return the complete path of downloaded file or an error

func ErrorPrintf

func ErrorPrintf(format string, a ...interface{}) (n int, err error)

ErrorPrintf print an error txt

func ExtractEncodedArrayFields

func ExtractEncodedArrayFields(param map[string]string, data []map[string]interface{}) []map[string]string

ExtractEncodedArrayFields is used to filter and safestring an array of data map got from a query

func ExtractEncodedFields

func ExtractEncodedFields(param map[string]string, data map[string]interface{}) map[string]string

ExtractEncodedFields is used to filter and safestring a data map got from a query

func GetContentFromS3

func GetContentFromS3(bucket string, bucketFileConf string) ([]byte, error)

GetContentFromS3 will download the conf file from S3 and return the content as a file

func GetMonthProrata

func GetMonthProrata(startsAt time.Time, endsAt time.Time, mode int) float32

GetMonthProrata returns a float representing the number of monthes between two dates with the rounding rules given above

func InfoPrintf

func InfoPrintf(format string, a ...interface{}) (n int, err error)

InfoPrintf print an info txt

func ListObjects

func ListObjects(bucketName string) ([]string, error)

ListObjects returns a list of objects in a bucket name

func NoticePrintf

func NoticePrintf(format string, a ...interface{}) (n int, err error)

NoticePrintf print an notice txt

func RandomHex

func RandomHex(n int) string

RandomHex provides a random hexa string of n length

func Unzip

func Unzip(src string, dest string) ([]string, error)

Unzip will decompress a zip archive, moving all files. No folders will be created within the zip file (parameter 1) to an output directory (parameter 2).

func WarningPrintf

func WarningPrintf(format string, a ...interface{}) (n int, err error)

WarningPrintf print a warning txt

Types

This section is empty.

Jump to

Keyboard shortcuts

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