utils

package
v0.0.0-...-edcddae Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerPort = "31015"
	//GlobalDBVersion ...
	GlobalDBVersion            int = 1
	ConfigDatabaseDSN              = "CONFIG_DATABASE_DSN"
	ConfigDbMaxOpenConnections     = "CONFIG_DB_MAX_OPEN_CONNECTIONS"
	ConfigDbIdleConnections        = "CONFIG_DB_IDLE_CONNECTIONS"
	ConfigServerPort               = "CONFIG_SERVER_PORT"
)

Variables

View Source
var DefaultFieldsToIgnore = []string{"created", "updated", "deleted"}
View Source
var MT5_MIN_DATE = time.Now().UTC().Add(time.Hour * 24 * 18000 * -1).Unix()

Functions

func AsSha256

func AsSha256(o interface{}) string

AsSha256 hash function

func AsSha256OfOrderedMap

func AsSha256OfOrderedMap(o map[string]interface{}, orderedKey []string) string

AsSha256OfOrderedMap hash function My tests showed this is unnecessary because apparently, the order of the key is the same if the content of the row is the same. So, two rows could have different field order, but it should be always the same for the specific row

func CleanAndTrim

func CleanAndTrim(text string) string

CleanAndTrim just alphanumeric chars

func ExecScript

func ExecScript(ctx context.Context, model interface{}, sql string, dbCon *sqlx.DB, ignoreFields []string) (int64, error)

ExecScript runs que SQL

func NumericHash

func NumericHash(ac interface{}) int64

func StructToSlice

func StructToSlice(st interface{}, ignoreFields []string) ([]interface{}, []string)

StructToSlice return field name and its values from a struct

Types

type Config

type Config struct {
	Database
}

type Database

type Database struct {
	DSN                string
	MaxOpenConnections string
	MaxIdleConnections string
}

type OverTransactionAdditionalQueries

type OverTransactionAdditionalQueries func(con *pgxpool.Conn) error

OverTransactionAdditionalQueries allow you to runs additional taks over the openned transaction

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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