go_library

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Unlicense Imports: 46 Imported by: 0

README

go-library

Backend Golang Library

Documentation

Overview

aes256.go Author Andrey Izman <izmanw@gmail.com> Copyright 2018 Andrey Izman License MIT

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLogError

func AddLogError(message string)

func AddLogErrorWithFields

func AddLogErrorWithFields(message string, param map[string]interface{})

func AddLogInfo

func AddLogInfo(message string)

func AddLogInfoWithFields

func AddLogInfoWithFields(message string, param map[string]interface{})

func AddLogWarn

func AddLogWarn(message string)

func AddLogWarnWithFields

func AddLogWarnWithFields(message string, param map[string]interface{})

func CheckNetConnect

func CheckNetConnect(host string, ports []string) map[int64]bool

func CopyFile

func CopyFile(src, dst string) (int64, error)

func Decrypt

func Decrypt(encrypted string) string

func DecryptWithKey

func DecryptWithKey(encrypted string, passphrase string) string

Decrypts encrypted text with the passphrase

func Encrypt

func Encrypt(text string) string

func EncryptWithKey

func EncryptWithKey(text string, passphrase string) string

Encrypts text with the passphrase

func GenUUID

func GenUUID() string

func GetFieldInteger

func GetFieldInteger(e interface{}, field string) int

func GetFieldString

func GetFieldString(e interface{}, field string) string

func GetIpFromDomain

func GetIpFromDomain(domain string) string

func GetIpOutbound

func GetIpOutbound() (ip string, err error)

func InInt64Slice

func InInt64Slice(val int64, slice []int64) (int, bool)

func InStringSlice

func InStringSlice(val string, slice []string) (int, bool)

func IsFloat

func IsFloat(s string) bool

func IsInteger

func IsInteger(s string) bool

func IsLetterOrSpace

func IsLetterOrSpace(s string) bool

func IsStringJSON

func IsStringJSON(str string) bool

func LoggerInit

func LoggerInit()

func MD5

func MD5(s string) string

func RemoveDirectory

func RemoveDirectory(dir string) error

func SendMail

func SendMail(param map[string]interface{}) error

func SliceExists

func SliceExists(slice interface{}, item interface{}) bool

func ToDate

func ToDate(s string) time.Time

func ToFloat64

func ToFloat64(s string, default_value float64) float64

func ToInt64

func ToInt64(s string, default_value int64) int64

func Unrar

func Unrar(src, dest string) error

func Unzip

func Unzip(src, dest string) error

func VarDump

func VarDump(data interface{})

func VarDumpToString

func VarDumpToString(data interface{}) string

func Var_dump

func Var_dump(expression ...interface{})

Types

type App

type App struct {
	BaseURL        string
	ApiVersion     string
	PageStartTime  time.Time
	NOW            string
	CLIENT_BUILD   string
	CLIENT_VERSION string
	DEVICE_MODEL   string
	OS_VERSION     string

	AppID       string
	DefaultRole string
	UserID      string
	RoleID      string
	OfficeCode  string
	Localize    string

	Log      logRequest
	Response responese
}

type CSVClientReaderOption

type CSVClientReaderOption struct {
	RowHeaderAt            int64
	RowDataAt              int64
	Delimiter              rune
	NumberColumName        []string
	NumberColumIndex       []int64
	OnImportProcessEachRow func(index_no int64, data []string, err error) (bool, []string)
}

----- >> Import From CSV to Excel

type CsvWriterOption

type CsvWriterOption struct {
	FolderPath             string
	FileNamePattern        string
	MaxRowPerFile          int64
	CsvDelimiter           string
	HideRowHeader          bool
	FirstRowHeader         string
	ChecksumFileName       string
	ChecksumContentPattern string
}

type DBClient

type DBClient struct {
	IsConnected bool
	// contains filtered or unexported fields
}

func (*DBClient) Backup

func (d *DBClient) Backup(filename string) (string, error)

func (*DBClient) BulkImport

func (d *DBClient) BulkImport(filename string, destination_table string, row_data_at int64) (string, error)

func (*DBClient) DbToCsv

func (d *DBClient) DbToCsv(sql string, opt ...CsvWriterOption) (string, error)

func (*DBClient) DbToExcel

func (d *DBClient) DbToExcel(sql string, opt ...ExcelClientWriterOption) (string, error)

func (*DBClient) GetColumns

func (d *DBClient) GetColumns(dbName string, tableName string) ([]*DbColumnInfo, error)

func (*DBClient) GetData

func (d *DBClient) GetData(asSQL string) (string, error)

func (*DBClient) GetDatabases

func (d *DBClient) GetDatabases() ([]string, error)

func (*DBClient) GetTables

func (d *DBClient) GetTables() ([]*DbTableInfo, error)

func (*DBClient) Paging

func (d *DBClient) Paging(asSQL string, aiPage int64, aiPageSize int64) (DataPaging, error)

func (*DBClient) Query

func (d *DBClient) Query(asSQL string) ([]map[string]string, error)

func (*DBClient) Restore

func (d *DBClient) Restore(filename string) (string, error)

func (*DBClient) TaskAbort

func (d *DBClient) TaskAbort(id string) (string, error)

func (*DBClient) TaskList

func (d *DBClient) TaskList() (map[string]interface{}, error)

func (*DBClient) TaskStatus

func (d *DBClient) TaskStatus(id string) (map[string]string, error)

type DataPaging

type DataPaging struct {
	Page       int64       `json:"page"`
	NumPage    int64       `json:"num_page"`
	Total      int64       `json:"total"`
	RowPerPage int64       `json:"row_per_page"`
	Rows       interface{} `json:"rows"`

	SqlCount             string  `json:"-"`
	SqlCountTimeStart    int64   `json:"-"`
	SqlCountTimeEnd      int64   `json:"-"`
	SqlCountTimeDuration float64 `json:"-"`

	SqlPaging             string  `json:"-"`
	SqlPagingTimeStart    int64   `json:"-"`
	SqlPagingTimeEnd      int64   `json:"-"`
	SqlPagingTimeDuration float64 `json:"-"`
}

type DbClient

type DbClient struct {
	// contains filtered or unexported fields
}

func NewDbclient

func NewDbclient(param DbClientOption) (*DbClient, error)

func (*DbClient) Close

func (d *DbClient) Close() error

func (*DbClient) Connect

func (d *DbClient) Connect() error

func (*DbClient) DbfToChar

func (d *DbClient) DbfToChar(as_input string) string

func (*DbClient) DbfToLongChar

func (d *DbClient) DbfToLongChar(as_input string) string

func (*DbClient) Delete

func (d *DbClient) Delete(table string, criteria map[string]interface{}) (sql.Result, error)

func (*DbClient) Exec

func (d *DbClient) Exec(sql string, args ...any) (sql.Result, error)

func (*DbClient) ExecAsync

func (d *DbClient) ExecAsync(ctx context.Context, sql string, args ...any) string

func (*DbClient) ExecContext

func (d *DbClient) ExecContext(ctx context.Context, sql string, args ...any) (sql.Result, error)

func (*DbClient) FindAll

func (d *DbClient) FindAll(sql string, args ...any) ([]map[string]interface{}, []*DbColumnInfo, error)

func (*DbClient) FindAllContext

func (d *DbClient) FindAllContext(ctx context.Context, sql string, args ...any) ([]map[string]interface{}, []*DbColumnInfo, error)

func (*DbClient) FindAllString

func (d *DbClient) FindAllString(sql string, args ...any) ([]map[string]string, []*DbColumnInfo, error)

func (*DbClient) FindAllStringContext

func (d *DbClient) FindAllStringContext(ctx context.Context, sql string, args ...any) ([]map[string]string, []*DbColumnInfo, error)

func (*DbClient) FirstRow

func (d *DbClient) FirstRow(sql string, args ...any) (map[string]interface{}, []*DbColumnInfo, error)

func (*DbClient) FirstRowContext

func (d *DbClient) FirstRowContext(ctx context.Context, sql string, args ...any) (map[string]interface{}, []*DbColumnInfo, error)

func (*DbClient) FirstRowString

func (d *DbClient) FirstRowString(sql string, args ...any) (map[string]string, []*DbColumnInfo, error)

func (*DbClient) FirstRowStringtContext

func (d *DbClient) FirstRowStringtContext(ctx context.Context, sql string, args ...any) (map[string]string, []*DbColumnInfo, error)

func (*DbClient) FirstValue

func (d *DbClient) FirstValue(sql string, args ...any) (interface{}, error)

func (*DbClient) FirstValueContext

func (d *DbClient) FirstValueContext(ctx context.Context, sql string, args ...any) (interface{}, error)

func (*DbClient) FirstValueString

func (d *DbClient) FirstValueString(sql string, args ...any) (string, error)

func (*DbClient) FirstValueStringContext

func (d *DbClient) FirstValueStringContext(ctx context.Context, sql string, args ...any) (string, error)

func (*DbClient) GetColumns

func (d *DbClient) GetColumns(databaseName string, schemaName string, tableName string) ([]*DbColumnInfo, error)

func (*DbClient) GetConfig

func (d *DbClient) GetConfig() DbClientOption

func (*DbClient) GetDatabases

func (d *DbClient) GetDatabases(filter ...string) ([]*DbDatabaseInfo, error)

func (*DbClient) GetSchemas

func (d *DbClient) GetSchemas(databaseName ...string) ([]*DbSchemaInfo, error)

func (*DbClient) GetTables

func (d *DbClient) GetTables(databaseName ...string) ([]*DbTableInfo, error)

func (*DbClient) GetViews

func (d *DbClient) GetViews(databaseName ...string) ([]*DbViewInfo, error)

func (*DbClient) GetWhere

func (d *DbClient) GetWhere(table string, condition string, param ...interface{}) (map[string]string, error)

func (*DbClient) Insert

func (d *DbClient) Insert(table string, data map[string]interface{}, suffixQueryArgs ...string) (int64, error)

func (*DbClient) Paging

func (d *DbClient) Paging(aiPage int64, aiPageSize int64, sql string, args ...any) (*DataPaging, error)

func (*DbClient) PagingContext

func (d *DbClient) PagingContext(ctx context.Context, aiPage int64, aiPageSize int64, sql string, args ...any) (*DataPaging, error)

func (*DbClient) Query

func (d *DbClient) Query(sql string, args ...any) (*sql.Rows, error)

func (*DbClient) QueryContext

func (d *DbClient) QueryContext(ctx context.Context, sql string, args ...any) (*sql.Rows, error)

func (*DbClient) QueryRows

func (d *DbClient) QueryRows(sql string, args ...any) (*DbRows, error)

func (*DbClient) QueryRowsContext

func (d *DbClient) QueryRowsContext(ctx context.Context, sql string, args ...any) (*DbRows, error)

func (*DbClient) SetConnMaxIdleTime

func (d *DbClient) SetConnMaxIdleTime(duration time.Duration)

func (*DbClient) SetConnMaxLifetime

func (d *DbClient) SetConnMaxLifetime(duration time.Duration)

func (*DbClient) SetMaxIdleConns

func (d *DbClient) SetMaxIdleConns(n int)

func (*DbClient) SetMaxOpenConns

func (d *DbClient) SetMaxOpenConns(n int)

func (*DbClient) Update

func (d *DbClient) Update(table string, data map[string]interface{}, criteria map[string]interface{}) (sql.Result, error)

type DbClientOption

type DbClientOption struct {
	DbType          string
	Host            string
	Port            int
	User            string
	Password        string
	Database        string
	DefaultSchema   string
	PostgresSslMode string
	AppTimeZone     *time.Location
	DbTimeZone      *time.Location
}

type DbColumnInfo

type DbColumnInfo struct {
	// TableName    string
	ColumnName   string
	FieldType    string
	DatabaseType string
	ColumnLength int64
	Precision    int64
	IsRequired   bool
	IsPrimaryKey bool
	Sequence     int64
}

type DbDatabaseInfo

type DbDatabaseInfo struct {
	DatabaseName  string
	CollationName string
	CreatedTime   string
}

type DbRows

type DbRows struct {
	ColumnInfo    []*DbColumnInfo
	ErrColumnType error

	SqlTimeStart    int64
	SqlTimeEnd      int64
	SqlTimeDuration float64

	IndexRow   int64
	FetchSpeed int64
	// contains filtered or unexported fields
}

func (*DbRows) ExportToCsv

func (d *DbRows) ExportToCsv(csvConfig CsvWriterOption) (string, int64, error)

func (*DbRows) FetchInterfaceRows

func (d *DbRows) FetchInterfaceRows(processRowFunc func(idx int64, arrColumn []*DbColumnInfo, mapRow map[string]interface{}) bool) (int64, error)

func (*DbRows) FetchStringRows

func (d *DbRows) FetchStringRows(processRowFunc func(idx int64, arrColumn []*DbColumnInfo, mapRow map[string]string) bool) (int64, error)

type DbSchemaInfo

type DbSchemaInfo struct {
	DatabaseName string
	SchemaName   string
	SchemaOwner  string
}

type DbTableInfo

type DbTableInfo struct {
	TableSchema    string
	TableName      string
	TableType      string
	TablespaceName string
	CreateDate     string
	ModifyDate     string
	NumRows        int64
	TotalSpaceKb   float64
}

type DbViewInfo

type DbViewInfo struct {
	TableSchema    string
	TableName      string
	ViewDefinition string
	Definer        string
}

type ExcelClient

type ExcelClient struct {
	// contains filtered or unexported fields
}

----- >> Base Excel Client

func NewExcelClient

func NewExcelClient() ExcelClient

----- >> Init Excel Client

func (*ExcelClient) AddRowData

func (d *ExcelClient) AddRowData(row []interface{}) error

----- >> Add Excel Row Data

func (*ExcelClient) AddRowHeader

func (d *ExcelClient) AddRowHeader(row []interface{}) error

----- >> Add Excel Row Header

func (*ExcelClient) Close

func (d *ExcelClient) Close() error

func (*ExcelClient) Create

func (d *ExcelClient) Create(file_name string, file_path string, opt ...ExcelClientWriterOption) error

----- >> Create Excel

func (*ExcelClient) FetchRow

func (d *ExcelClient) FetchRow() (string, int64, []string, error)

func (*ExcelClient) GetBasePath

func (d *ExcelClient) GetBasePath() string

func (*ExcelClient) ImportFromCSV

func (d *ExcelClient) ImportFromCSV(file_path string, opt ...CSVClientReaderOption) (int64, error)

func (*ExcelClient) ImportFromRowStream

func (d *ExcelClient) ImportFromRowStream(rows *sql.Rows, f_process_each_row func(index_no int64, column []string, data []interface{}) (bool, []interface{})) (int64, error)

func (*ExcelClient) Read

func (d *ExcelClient) Read(file_path string, opt ...ExcelClientReaderOption) ([]string, error)

func (*ExcelClient) Save

func (d *ExcelClient) Save() (string, error)

----- >> Save Excel

type ExcelClientReaderOption

type ExcelClientReaderOption struct {
	Password    string
	RowHeaderAt int64
	RowDataAt   int64
}

type ExcelClientWriterOption

type ExcelClientWriterOption struct {
	FileName              string
	FilePath              string
	FileNamePattern       string
	SheetName             string
	MaxRowPerFile         int64
	ColWidth              []float64
	NumberTypeColumn      []string
	UseRowNo              bool
	FirstRowHeader        []interface{}
	FirstRowHeaderMapping map[string]string

	OutputFileSkipCompression bool
}

type FtpClient

type FtpClient struct {
	Address  string `json:"host"`
	Port     int    `json:"port"`
	UserName string `json:"user_name"`
	Password string `json:"-"`
	Sftp     bool   `json:"sftp"`
	// contains filtered or unexported fields
}

----- >> Base Ftp Client

func NewFtpClient

func NewFtpClient(address string, port int, userName string, password string, sftp ...bool) (*FtpClient, error)

----- >> Init Ftp Client

func (*FtpClient) ChangeDir

func (d *FtpClient) ChangeDir(directory string) error

----- >> Change FTP Directory

func (*FtpClient) Connect

func (d *FtpClient) Connect() error

----- >> Connect FTP

func (*FtpClient) CurrentDir

func (d *FtpClient) CurrentDir() (string, error)

----- >> Get Current Dir

func (*FtpClient) Delete

func (d *FtpClient) Delete(filePath string) error

func (*FtpClient) Download

func (d *FtpClient) Download(ftp_source_path string, local_target_path string) error

----- >> Download file from FTP Directory

func (*FtpClient) GetList

func (d *FtpClient) GetList(directory string) ([]*ftp.Entry, error)

----- >> Get List Entries from FTP Directory

func (*FtpClient) GetStringFileType

func (d *FtpClient) GetStringFileType(t ftp.EntryType) string

func (*FtpClient) IsConnected

func (d *FtpClient) IsConnected() bool

func (*FtpClient) IsInProgress

func (d *FtpClient) IsInProgress() bool

func (*FtpClient) MakeDir

func (d *FtpClient) MakeDir(path string) error

----- >> Make Dir

func (*FtpClient) Quit

func (d *FtpClient) Quit() error

----- >> Close FTP Connection

func (*FtpClient) Upload

func (d *FtpClient) Upload(local_source_path string, ftp_target_path string) error

----- >> Upload to FTP Directory

type Rest

type Rest struct {
	// contains filtered or unexported fields
}

----- >> Base Rest Client

func NewRestClient

func NewRestClient() Rest

----- >> Init Rest

func (*Rest) ClearHeaders

func (this *Rest) ClearHeaders()

func (*Rest) Curl

func (this *Rest) Curl(rest_method string, rest_url string, data_url map[string]string, form_type string, data_body map[string]interface{}, output_path string) (string, error)

func (*Rest) CurlBinary

func (this *Rest) CurlBinary(rest_method string, rest_url string, data_url map[string]string, form_type string, data_body map[string]interface{}, timeout int64) (*http.Response, error)

func (*Rest) Delete

func (this *Rest) Delete(rest_url string, data map[string]string) (string, error)

func (*Rest) Get

func (this *Rest) Get(rest_url string, data map[string]string) (string, error)

----- >> Execute Rest Client

func (*Rest) GetDownload

func (this *Rest) GetDownload(rest_url string, form_type string, data map[string]string, output_path string) (string, error)

func (*Rest) GetFileContentType

func (this *Rest) GetFileContentType(out *os.File) (string, error)

func (*Rest) GetHeader

func (this *Rest) GetHeader(key string) (string, bool)

func (*Rest) GetHeaders

func (this *Rest) GetHeaders() map[string]string

func (*Rest) Post

func (this *Rest) Post(rest_url string, form_type string, data map[string]interface{}) (string, error)

func (*Rest) PostDownload

func (this *Rest) PostDownload(rest_url string, form_type string, data map[string]interface{}, output_path string) (string, error)

func (*Rest) Put

func (this *Rest) Put(rest_url string, form_type string, data map[string]interface{}) (string, error)

func (*Rest) RemoveHeader

func (this *Rest) RemoveHeader(key string)

func (*Rest) SetHeader

func (this *Rest) SetHeader(key string, value string)

----- >> Header Request Modification

func (*Rest) SetHeaders

func (this *Rest) SetHeaders(header map[string]string)

func (*Rest) SetIdleConnTimeout

func (this *Rest) SetIdleConnTimeout(idleConnTimeout int64)

func (*Rest) SetMaxIdleConns

func (this *Rest) SetMaxIdleConns(maxIdleConns int)

----- >> Timeout Configuration

func (*Rest) SetMaxIdleConnsPerHost

func (this *Rest) SetMaxIdleConnsPerHost(maxIdleConnsPerHost int)

func (*Rest) SetSSLInsecureSkipVerify

func (this *Rest) SetSSLInsecureSkipVerify(value bool)

func (*Rest) SetTimeout

func (this *Rest) SetTimeout(timeout int64)

type RestClient

type RestClient struct {
	IsConnected bool
	// contains filtered or unexported fields
}

----- >> Rest

func (*RestClient) ClearHeaders

func (d *RestClient) ClearHeaders()

func (*RestClient) Delete

func (d *RestClient) Delete(rest_url string, data map[string]string) (string, error)

func (*RestClient) Get

func (d *RestClient) Get(rest_url string, data map[string]string) (string, error)

func (*RestClient) GetHeader

func (d *RestClient) GetHeader(key string) (string, bool)

func (*RestClient) GetHeaders

func (d *RestClient) GetHeaders() map[string]string

func (*RestClient) Post

func (d *RestClient) Post(rest_url string, form_type string, data map[string]interface{}) (string, error)

func (*RestClient) Put

func (d *RestClient) Put(rest_url string, form_type string, data map[string]interface{}) (string, error)

func (*RestClient) RemoveHeader

func (d *RestClient) RemoveHeader(key string)

func (*RestClient) SetHeader

func (d *RestClient) SetHeader(key string, value string)

func (*RestClient) SetHeaders

func (d *RestClient) SetHeaders(header map[string]string)

type TaskClient

type TaskClient struct {
	IsConnected bool
	// contains filtered or unexported fields
}

----- >> Base Task Client

func NewTaskClient

func NewTaskClient(url string, proxy []string) (TaskClient, error)

----- >> Init Task Client

func (*TaskClient) FileCompress

func (d *TaskClient) FileCompress(filename []string, delete_after_compress bool) (string, error)

func (*TaskClient) FileDelete

func (d *TaskClient) FileDelete(filename string) (string, error)

func (*TaskClient) FileDownload

func (d *TaskClient) FileDownload(filename string, download_path string) (string, error)

func (*TaskClient) FileExists

func (d *TaskClient) FileExists(filename string) (string, error)

----- >> File Operation

func (*TaskClient) FileExtract

func (d *TaskClient) FileExtract(filename string, delete_after_extract bool) (string, error)

func (*TaskClient) FileRename

func (d *TaskClient) FileRename(filename string, new_filename string) (string, error)

func (*TaskClient) FileTaskList

func (d *TaskClient) FileTaskList() (map[string]map[string]map[string]interface{}, error)

func (*TaskClient) FileTaskStatus

func (d *TaskClient) FileTaskStatus(id string) (map[string]string, error)

func (*TaskClient) FileUpload

func (d *TaskClient) FileUpload(file_path string) (string, error)

func (*TaskClient) GitBranch

func (d *TaskClient) GitBranch(path string) (string, error)

func (*TaskClient) GitPull

func (d *TaskClient) GitPull(path string) (string, error)

----- >> Git

func (*TaskClient) GitStatus

func (d *TaskClient) GitStatus(path string) (string, error)

func (*TaskClient) GitVersion

func (d *TaskClient) GitVersion() (string, error)

func (*TaskClient) GoBuild

func (d *TaskClient) GoBuild(path string, output ...string) (string, error)

----- >> Go

func (*TaskClient) GoVersion

func (d *TaskClient) GoVersion() (string, error)

func (*TaskClient) NewDbClient

func (d *TaskClient) NewDbClient(dbcon_type string, dbcon_host string, dbcon_port string, dbcon_dbname string, dbcon_user string, dbcon_pass string) (DBClient, error)

----- >> DB Operation

func (*TaskClient) NewFtpClient

func (d *TaskClient) NewFtpClient(address string, port int, userName string, password string, sftp ...bool) (TcFtpClient, error)

----- >> FTP Operation

func (*TaskClient) NewRestClient

func (d *TaskClient) NewRestClient() RestClient

func (*TaskClient) ServiceStart

func (d *TaskClient) ServiceStart(service_name string) (string, error)

----- >> OS Service

func (*TaskClient) ServiceStop

func (d *TaskClient) ServiceStop(service_name string) (string, error)

func (*TaskClient) SystemCheckDomain

func (d *TaskClient) SystemCheckDomain(domain string) (string, error)

func (*TaskClient) SystemInfo

func (d *TaskClient) SystemInfo() (map[string]interface{}, error)

----- >> System Info

func (*TaskClient) SystemMemory

func (d *TaskClient) SystemMemory() (map[string]interface{}, error)

func (*TaskClient) SystemNetConnect

func (d *TaskClient) SystemNetConnect(host string, arr_port []int) (map[int64]bool, error)

type TcFtpClient

type TcFtpClient struct {
	// contains filtered or unexported fields
}

func (*TcFtpClient) Download

func (d *TcFtpClient) Download(ftp_source string, local_destination string) (string, error)

func (*TcFtpClient) TaskList

func (d *TcFtpClient) TaskList() (map[string]map[string]map[string]string, error)

func (*TcFtpClient) TaskStatus

func (d *TcFtpClient) TaskStatus(id string) (map[string]string, error)

func (*TcFtpClient) Upload

func (d *TcFtpClient) Upload(local_source string, ftp_destination string) (string, error)

Jump to

Keyboard shortcuts

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