cuppago

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 25 Imported by: 0

README

cuppa-go

All-purpose library

Installation

go get -u github.com/cloudbit-interactive/cuppago

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(value string) string

func Base64Encode

func Base64Encode(string string) string

func Camelize

func Camelize(in string) string

func CompareHash

func CompareHash(hash string, value string) bool

func CreateFolder

func CreateFolder(path string)

func Decrypt added in v0.0.3

func Decrypt(encryptedString string, keyString string) (decryptedString string)

Example: decryptedText := Decrypt("MyEncryptedText", "256-bit-key-generator") Key generator = https://www.allkeysgenerator.com/Random/Security-Encryption-Key-Generator.aspx

func Encrypt added in v0.0.3

func Encrypt(stringToEncrypt string, keyString string) (encryptedString string)

Example: encryptedText := Encrypt("MyText", "256-bit-key-generator") Key generator = https://www.allkeysgenerator.com/Random/Security-Encryption-Key-Generator.aspx

func Error

func Error(values ...interface{})

func FormToMap

func FormToMap(r *http.Request) map[string]interface{}

func GetRequestBody

func GetRequestBody(r *http.Request) string

func GetRootPath

func GetRootPath() string

func Goroutines

func Goroutines(intervalTime time.Duration)

func Hash

func Hash(value string) string

func InterfaceToString

func InterfaceToString(value interface{}) string

func IsNil

func IsNil(a interface{}) bool

func JSONDecode

func JSONDecode(value string, base64Decode bool) interface{}

data := utils.JSONDecode(string, false)

func JSONEncode

func JSONEncode(value interface{}, base64Encode bool) string

func JSONToMap

func JSONToMap(element interface{}) map[string]interface{}

func Log

func Log(values ...interface{})

func LogFile

func LogFile(values ...interface{})

func MapListToStructure

func MapListToStructure(list []map[string]interface{}, s interface{})

func MapToStruct

func MapToStruct(data map[string]interface{}, structPointer interface{})

Example: var user User; utils.MapToStruct(result, &user)

func MapToStructure

func MapToStructure(m map[string]interface{}, s interface{})

func MergeObjects

func MergeObjects(values ...map[string]interface{}) map[string]interface{}

func PathData

func PathData(path string) map[string]interface{}

func ReplaceNotCase

func ReplaceNotCase(value string, search string, replace string) string

func SendAndLoad

func SendAndLoad(url string, data interface{}) string

func String

func String(value interface{}) string

Parse any value to String

func StructureToMap

func StructureToMap(element interface{}) map[string]interface{}

func Type

func Type(value interface{}) string

func URLToMap

func URLToMap(urlString string) map[string]interface{}

func UUID

func UUID() string

func Value

func Value(data interface{}, path string, defaultValue interface{}) interface{}

func Wait

func Wait(values ...interface{})

Types

type DataBase

type DataBase struct {
	Host     string
	Port     string
	Db       string
	Username string
	Password string
	Conn     *sql.DB
}

DataBase : DataBase Structure

func NewDataBase

func NewDataBase(host string, db string, username string, password string, port string) DataBase

Example: db := cuppago.NewDataBase("localhost","golang", "root", "", "")

func (*DataBase) Add

func (db *DataBase) Add(table string, data map[string]interface{}, condition string, columnsToReturn string) map[string]interface{}

Add : Check if record exist if exist update it or create one

func (*DataBase) Delete

func (db *DataBase) Delete(table string, condition string) map[string]interface{}

Delete : Delete a record from a specific table

func (*DataBase) GetList

func (db *DataBase) GetList(table string, condition string, limit string, orderBy string, columns string) []map[string]interface{}

Example: data := db.GetList("users", "", "", "", "")

func (*DataBase) GetMap

func (db *DataBase) GetMap(rows *sql.Rows) []map[string]interface{}

GetMap : Extract a map of a sql.Rows

func (*DataBase) GetRow

func (db *DataBase) GetRow(table string, condition string, orderBy string, columns string) map[string]interface{}

GetRow : Get a map of data from a specific table

func (*DataBase) GetTables

func (db *DataBase) GetTables() []map[string]interface{}

func (*DataBase) Insert

func (db *DataBase) Insert(table string, data map[string]interface{}, columnsToReturn string) map[string]interface{}

Example: data := map[string]interface{}{"name":"Tufik","age":50, "date":"NOW()"} db.Insert("users", data, "")

func (*DataBase) SQL

func (db *DataBase) SQL(query string) []map[string]interface{}

SQL : Execute any sql and return it result

func (*DataBase) TestConnection

func (db *DataBase) TestConnection() bool

func (*DataBase) Update

func (db *DataBase) Update(table string, data map[string]interface{}, condition string, columnsToReturn string) map[string]interface{}

Update : Update data in a specific table

Jump to

Keyboard shortcuts

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