goutils

package module
v1.19.3 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: MIT Imports: 42 Imported by: 4

README

Module goutils

Functions used in everyday life that help a lot.

Dependencia
go get go.mongodb.org/mongo-driver@v1.1.0

Installation

$ go get github.com/armando-couto/goutils

Methods

arquivo.go
ListFolderFiles(path string) Return []os.FileInfo
ReadingFiles(path string, fileName string) Return string
RemoveFilesOfPath(path string) Return void
ReturnsTheRows(text string) Return []string
CreateDirectory(directory string) Return bool
CreateArchiveNodirectory(nomeDoArquivo string, conteudo string) Return error
IsError(err error) Return bool
Backup(path, name, texto string) Return void
array.go
ContainsToStringInArray(a []string, x string) Return int
aws_sqs.go
ConectionSQS() Return *sqs.SQS
TokenGeneratorMessageId() Return string
base64.go
EncodeStringToBase64(value string) Return string
DecodeBase64ToString(value string) Return string
bool.go
ContainsToStringInArrayReturnBool(a []string, x string) Return bool
cpf_cnpj.go
ValidationCPF(cpf string) Return error
ValidationCNPJ(cnpj string) Return error
csv.go
CSVGZExport(StructCsv [][]string, nomeArquivo string) Return error
CSVRead(pathFile string) Return [][]string
GeneratorFilesGen(payload []interface{}, f func ([][]string) [][]string, nomeArq string) Return error
datetime.go
ConvertStringToTimeLayoutDDMMYYYY(value string) Return time.Time
ConvertTimeToStringLayoutDD_MM_YYYY(date time.Time) Return string
ConvertStringToTimeLayoutDD_MM_YYYY(value string) Return time.Time
ConvertStringToTimeLayoutDD_MM_YYYY_HH_MM_SS(value string) Return time.Time
ConvertStringDD_MM_YYYY(date string) Return time.Time
ConverTimeToStrinLayoutYYYY_MM_DD(data time.Time) Return string
ConvertStringToTimeLayoutYYYYMMDD(value string) Return time.Time
ConvertStringToTimeLayoutYYYY_MM_DD(value string) Return time.Time
ConverTimeToStrinLayoutYYYYMMDD(data time.Time) Return string
ConvertStringToTimeLayoutYYMMDDHHMMSS(value string) Return time.Time
ConvertStringToTimeLayoutYYYYMMDDHHMMSS(value string) Return time.Time
ConvertStringToTimeLayout_YYYY_MM_DD_HH_MM_SS(date time.Time) Return string
ConvertStringToTimeLayout_YYYY_MM_DD(date time.Time) Return string
ConvertStringToTimeLayoutYYYY_MM_DDTHH_MM_SS_000Z(value string) Return time.Time
ConvertStringToTimeLayoutYYYY_MM_DDTHH_MM_SS_000(value string) Return time.Time
ConvertStringToTimeLayoutHHMMSS(value string) Return time.Time
ConvertStringToTimeLayoutHH_MM_SS(value string) Return time.Time
ConvertStringToTimeLayoutDDMMYYYYHHMMSS(d time.Time, h time.Time) Return time.Time
RangeDate(end, start time.Time) func () Return time.Time
DatePlusTime(date, timeOfDay time.Time) Returns (time.Time, error)
WeekStartDate(date time.Time) time.Time
WeekEndDate(date time.Time) time.Time
environment.go
Godotenv(key string) Return string
float.go
Subtract(valo1, valor2 float64) Return float64
ConvertFloatToFloatScale2(valor float64) Return float64
ConvertFloat64ToString(value float64) Return string
ConvertFloat64ToString4Decimal(value string) Return float64
ConvertStringToFloat64(value string) Return float64
ConvertStringToFloatScale2Comma(value string) Return float64
ConvertStringToFloatScale2FormatNumber(value string) Return float64
ConvertStringToFloatScale2(value string) Return float64
ConvertFloatToBrMoneyString(value float64) Return string
ftp.go
ListOfAvailableFilesNoFTP(remote string, port string, user string, pass string) Returns (*ftp.ServerConn, error, []string)
GetHostKey(host string, isProduction bool) Return ssh.PublicKey
integer.go
ContainsInt(a []int, x int) Return bool
ConvertStringToInt5Digits(value string) Return int
ConvertStringToInt(value string) Return int
ConvertIntToString(value int) Return string
logger_file.go
CreateFileDay(message interface{}) Return void
mysql_connection.go
ConnectionBDMySQL() Return *sql.DB
psql_connection.go
ConnectionBDPostgreSQL() Return *sql.DB
ConnectionBDPostgreSQLORM() Return (DB *gorm.DB)
string.go
RemoveZerosInLeft(value string) Return string
RemoveSpaceString(value string) Return string
RemoveCharacters(value string) Return string
StandardizesMasksByCard(numeroCartao string) Return string
StringTrim(value string) Return string
RemoveSpecialCharacters(value string) Return string
RandSeq(n int) Return string
TokenGeneratorNLength(length int) Return string
TokenGeneratorOrderReferenceId() Return string
RemoveHeadHyphen(s string) Return string
ValidateIfNotEmptyNumber(valor string) Return string
ValidateIfNotEmptyDate(data string) Return string
RemoveCNPJMask(cnpj string) Return string
ParseBinToHex(s string) Return string
struct.go
CheckIfIdIfNotZero(objetoId int) Return interface{}
try_catch.go
Throw(up Exception) Return void
(tcf Block) Do() Return void
validacoes.go
MaskCard6Initials(cardString string) Return string
MaskLastDigits(card string) Return string
MaskCard(cardString string) Return string
ExpiryDate(valor string) Returns (string, string)
ValidateTelephone(telefone string) Return string
zip.go
ZipFiles(filename string, files []string) Return error
AddFileToZip(zipWriter *zip.Writer, filename string) Return error

Documentation

Index

Constants

View Source
const (
	DEFAULT_DATE                    = "0001-01-01"
	LAYOUT_DDMMYYYY                 = "02012006"
	LAYOUT_DD_MM_YYYY               = "02/01/2006"
	LAYOUT_DD_MM_YYYY_HH_MM_SS      = "02/01/2006 15:04:05"
	LAYOUT_YYYY_MM_DD_HH_MM_SS      = "2006-01-02 15:04:05"
	LAYOUT_MM_DD_YYYY_HH_MM         = "01-02-2006 15:04"
	LAYOUT_YYYYMMDD                 = "20060102"
	LAYOUT_YYMMDDHHMMSS             = "060102150405"
	LAYOUT_YYYYMMDDHHMMSS           = "20060102150405"
	LAYOUT_YYYYMM                   = "200601"
	LAYOUT_YYYY_MM_DD               = "2006-01-02"
	LAYOUT_YYMMDD                   = "060102"
	LAYOUT_HHMMSS                   = "150405"
	LAYOUT_HH                       = "15"
	LAYOUT_HH_MM_SS                 = "15:04:05"
	LAYOUT_YYYY_MM_DDTHH_MM_SS_000Z = "2006-01-02T15:04:05.000Z"
	LAYOUT_YYYY_MM_DDTHH_MM_SS      = "2006-01-02 15:04:05"
	LAYOUT_YYYY_MM_DDTHH_MM_SS_000  = "2006-01-02T15:04:05.000"
)

Variables

View Source
var AccessKeyID string
View Source
var MyRegion string
View Source
var SecretAccessKey string

Functions

func AddFileToZip added in v1.11.0

func AddFileToZip(zipWriter *zip.Writer, filename string) error

func Backup

func Backup(path, name, texto string)

Backup

func CSVGZExport

func CSVGZExport(StructCsv [][]string, nomeArquivo string) error

CSVGZExport o antigo nome era: CsvGzExport

func CSVRead

func CSVRead(pathFile string) [][]string

CSVRead o antigo nome era: CsvRead

func CheckIfIdIfNotZero

func CheckIfIdIfNotZero(objetoId int) interface{}

CheckIfIdIfNotZero o antigo nome era: ChecaSeIdSeNaoEstaZero

func ConectionSQS

func ConectionSQS() *sqs.SQS

ConectionSQS o antigo nome era: Svc

func ConnectAws added in v1.8.0

func ConnectAws() *session.Session

func ConnectionBDFirebird added in v1.18.0

func ConnectionBDFirebird() *sql.DB

func ConnectionBDMySQL

func ConnectionBDMySQL() *sql.DB

ConnectionBDMySQL o antigo nome era: ConexaoBDMySQL

func ConnectionBDPostgreSQL

func ConnectionBDPostgreSQL() *sql.DB

ConnectionBDPostgreSQL o antigo nome era: ConexaoDB

func ConnectionBDPostgreSQLORM

func ConnectionBDPostgreSQLORM() (DB *gorm.DB)

ConnectionBDPostgreSQLORM o antigo nome era: ConexaoBDORM

func ConnectionMongoDB added in v1.12.0

func ConnectionMongoDB() *mongo.Database

func ContainsInt

func ContainsInt(a []int, x int) bool

ContainsInt

func ContainsToStringInArray

func ContainsToStringInArray(a []string, x string) int

ContainsToStringInArray o antigo nome era: Contains

func ContainsToStringInArrayReturnBool

func ContainsToStringInArrayReturnBool(a []string, x string) bool

ContainsToStringInArrayReturnBool o antigo nome era: ContainsReturnBool

func ConverTimeToStrinLayoutYYYYMMDD

func ConverTimeToStrinLayoutYYYYMMDD(data time.Time) string

ConverTimeToStrinLayoutYYYYMMDD

func ConverTimeToStrinLayoutYYYY_MM_DD

func ConverTimeToStrinLayoutYYYY_MM_DD(data time.Time) string

ConverTimeToStrinLayoutYYYY_MM_DD

func ConvertFloat64ToString

func ConvertFloat64ToString(value float64) string

ConvertFloat64ToString

func ConvertFloat64ToString4Decimal added in v1.10.2

func ConvertFloat64ToString4Decimal(value float64) string

ConvertFloat64ToString4Decimal

func ConvertFloatToBrMoneyString added in v1.14.0

func ConvertFloatToBrMoneyString(value float64) string

ConvertFloatToBrMoneyString

func ConvertFloatToFloatScale2

func ConvertFloatToFloatScale2(valor float64) float64

ConvertFloatToFloatScale2

func ConvertIntToString

func ConvertIntToString(value int) string

ConvertStringToInt

func ConvertPassword added in v1.5.0

func ConvertPassword(password string) string

Hashing the password with the default cost of 10

func ConvertStringDD_MM_YYYY

func ConvertStringDD_MM_YYYY(date string) time.Time

ConvertStringDD_MM_YYYY

func ConvertStringToBool added in v1.12.1

func ConvertStringToBool(value string) bool

func ConvertStringToFloat64

func ConvertStringToFloat64(value string) float64

ConvertStringToFloat64

func ConvertStringToFloatScale2

func ConvertStringToFloatScale2(value string) float64

ConvertStringToFloatScale2

func ConvertStringToFloatScale2Comma

func ConvertStringToFloatScale2Comma(value string) float64

ConvertStringToFloatScale2Comma o antigo nome era: ConvertStringToFloatScale2Virgula

func ConvertStringToFloatScale2FormatNumber added in v1.4.1

func ConvertStringToFloatScale2FormatNumber(value string) float64

ConvertStringToFloatScale2Format o antigo nome era: ConvertStringToFloatScale2

func ConvertStringToInt

func ConvertStringToInt(value string) int

ConvertStringToInt

func ConvertStringToInt5Digits

func ConvertStringToInt5Digits(value string) int

ConvertStringToInt5Digits

func ConvertStringToTimeLayoutDDMMYYYY

func ConvertStringToTimeLayoutDDMMYYYY(value string) time.Time

ConvertStringToTimeLayoutDDMMYYYY

func ConvertStringToTimeLayoutDDMMYYYYHHMMSS

func ConvertStringToTimeLayoutDDMMYYYYHHMMSS(d time.Time, h time.Time) time.Time

ConvertStringToTimeLayoutDDMMYYYYHHMMSS

func ConvertStringToTimeLayoutDD_MM_YYYY

func ConvertStringToTimeLayoutDD_MM_YYYY(value string) time.Time

ConvertStringToTimeLayoutDD_MM_YYYY

func ConvertStringToTimeLayoutDD_MM_YYYY_HH_MM_SS

func ConvertStringToTimeLayoutDD_MM_YYYY_HH_MM_SS(value string) time.Time

ConvertStringToTimeLayoutDD_MM_YYYY_HH_MM_SS

func ConvertStringToTimeLayoutHHMMSS

func ConvertStringToTimeLayoutHHMMSS(value string) time.Time

ConvertStringToTimeLayoutHHMMSS

func ConvertStringToTimeLayoutHH_MM_SS

func ConvertStringToTimeLayoutHH_MM_SS(value string) time.Time

ConvertStringToTimeLayoutHH_MM_SS

func ConvertStringToTimeLayoutYYMMDDHHMMSS

func ConvertStringToTimeLayoutYYMMDDHHMMSS(value string) time.Time

ConvertStringToTimeLayoutYYMMDDHHMMSS

func ConvertStringToTimeLayoutYYYYMMDD

func ConvertStringToTimeLayoutYYYYMMDD(value string) time.Time

ConvertStringToTimeLayoutYYYYMMDD

func ConvertStringToTimeLayoutYYYYMMDDHHMMSS

func ConvertStringToTimeLayoutYYYYMMDDHHMMSS(value string) time.Time

ConvertStringToTimeLayoutYYYYMMDDHHMMSS

func ConvertStringToTimeLayoutYYYY_MM_DD

func ConvertStringToTimeLayoutYYYY_MM_DD(value string) time.Time

ConvertStringToTimeLayoutYYYY_MM_DD

func ConvertStringToTimeLayoutYYYY_MM_DDTHH_MM_SS added in v1.15.1

func ConvertStringToTimeLayoutYYYY_MM_DDTHH_MM_SS(value string) time.Time

ConvertStringToTimeLayoutYYYY_MM_DDTHH_MM_SS

func ConvertStringToTimeLayoutYYYY_MM_DDTHH_MM_SS_000

func ConvertStringToTimeLayoutYYYY_MM_DDTHH_MM_SS_000(value string) time.Time

ConvertStringToTimeLayoutYYYY_MM_DDTHH_MM_SS_000

func ConvertStringToTimeLayoutYYYY_MM_DDTHH_MM_SS_000Z

func ConvertStringToTimeLayoutYYYY_MM_DDTHH_MM_SS_000Z(value string) time.Time

ConvertStringToTimeLayoutYYYY_MM_DDTHH_MM_SS_000Z

func ConvertStringToTimeLayout_YYYY_MM_DD

func ConvertStringToTimeLayout_YYYY_MM_DD(date time.Time) string

ConvertStringToTimeLayout_YYYY_MM_DD o antigo nome era: ConvertStringToTimeLAYOUT_YYYY_MM_DD

func ConvertStringToTimeLayout_YYYY_MM_DD_HH_MM_SS

func ConvertStringToTimeLayout_YYYY_MM_DD_HH_MM_SS(date time.Time) string

ConvertStringToTimeLayout_YYYY_MM_DD_HH_MM_SS o antigo nome era: ConvertStringToTimeLAYOUT_YYYY_MM_DD_HH_MM_SS

func ConvertTimeToStringLayoutDD_MM_YYYY

func ConvertTimeToStringLayoutDD_MM_YYYY(date time.Time) string

ConvertTimeToStringLayoutDD_MM_YYYY

func ConvertTimeToStringLayoutMM_DD_YYYY_HH_MM added in v1.7.0

func ConvertTimeToStringLayoutMM_DD_YYYY_HH_MM(date time.Time) string

func ConvertTimeToStringLayoutYYYY_MM_DDTHH_MM_SS_000 added in v1.13.6

func ConvertTimeToStringLayoutYYYY_MM_DDTHH_MM_SS_000(date time.Time) string

ConvertTimeToStringLayoutYYYY_MM_DDTHH_MM_SS_000

func ConvertToTimeLayout_YYYY_MM_DD_HH_MM_SS added in v1.16.5

func ConvertToTimeLayout_YYYY_MM_DD_HH_MM_SS(value string) time.Time

func ConvertkeepZeroToFloat64 added in v1.15.0

func ConvertkeepZeroToFloat64(value KeepZero) float64

ConvertkeepZeroToFloat64

func ConvertkeepZeroToFloat64To4Decimal added in v1.17.0

func ConvertkeepZeroToFloat64To4Decimal(value KeepZero) float64

func CreateArchiveNodirectory

func CreateArchiveNodirectory(nomeDoArquivo string, conteudo string) error

CreateArchiveNodirectory o antigo nome era: CreateArchiveNodirectory

func CreateDirectory

func CreateDirectory(directory string) bool

CreateDirectory o antigo nome era: CriaDiretorio

func CreateFileDay

func CreateFileDay(message Message)

func CreateFileDayInfoNotDate added in v1.10.3

func CreateFileDayInfoNotDate(message string)

func DatePlusTime

func DatePlusTime(date, timeOfDay time.Time) (time.Time, error)

DatePlusTime

func DecodeBase64ToString

func DecodeBase64ToString(value string) string

DecodeBase64ToString

func EncodeStringToBase64

func EncodeStringToBase64(value string) string

EncodeStringToBase64

func ExpiryDate

func ExpiryDate(valor string) (string, string)

ExpiryDate o antigo nome era: ValidadeCartao

func GeneratePasswordCurrent added in v1.16.5

func GeneratePasswordCurrent() string

EncodeStringToBase64

func GeneratorFilesGen

func GeneratorFilesGen(payload []interface{}, f func([][]string) [][]string, nomeArq string) error

GeneratorFilesGen o antigo nome era: GeradorArquivosGen

func GetHostKey

func GetHostKey(host string, isProduction bool) ssh.PublicKey

GetHostKey: parse OpenSSH known_hosts file ssh or use ssh-keyscan to get initial key

func Godotenv

func Godotenv(key string) string

Godotenv

func InsertAudit added in v1.13.1

func InsertAudit(object interface{})

func IsError

func IsError(err error) bool

IsError o antigo nome era: IsError

func ListFolderFiles

func ListFolderFiles(path string) []os.FileInfo

ListFolderFiles o antigo nome era: ListarArquivosDaPasta

func ListOfAvailableFilesNoFTP

func ListOfAvailableFilesNoFTP(remote string, port string, user string, pass string) (*ftp.ServerConn, error, []string)

ListOfAvailableFilesNoFTP o antigo nome era: ListaDeArquivosDisponiveisNoFTP

func MaskCard

func MaskCard(cardString string) string

MaskCard

func MaskCard6Initials

func MaskCard6Initials(cardString string) string

MaskCard6Initials o antigo nome era: MaskCard6DigitosIniciais

func MaskLastDigits

func MaskLastDigits(card string) string

MaskLastDigits o antigo nome era: MaskUltimosDigitos

func ParseBinToHex

func ParseBinToHex(s string) string

ParseBinToHex

func RandSeq

func RandSeq(n int) string

RandSeq

func RangeDate

func RangeDate(end, start time.Time) func() time.Time

RangeDate returns a date range function over start date to end date inclusive. After the end of the range, the range function returns a zero date, date.IsZero() is true.

func ReadingFiles

func ReadingFiles(path string, fileName string) string

ReadingFiles o antigo nome era: LeituraDosArquivos

func RemoveCNPJMask

func RemoveCNPJMask(cnpj string) string

RemoveCNPJMask o antigo nome era: RemoveMascaraCNPJ

func RemoveCharacters

func RemoveCharacters(value string) string

RemoveCharacters o antigo nome era: RemoveCaracteres

func RemoveFilesOfPath

func RemoveFilesOfPath(path string)

RemoveFilesOfPath o antigo nome era: RemoveFile

func RemoveHeadHyphen

func RemoveHeadHyphen(s string) string

RemoveHeadHyphen o antigo nome era: RetiraPontoHifen

func RemoveSpaceString

func RemoveSpaceString(value string) string

RemoveSpaceString o antigo nome era: TirarEspacoString

func RemoveSpecialCharacters

func RemoveSpecialCharacters(value string) string

RemoveSpecialCharacters

func RemoveZerosInLeft

func RemoveZerosInLeft(value string) string

RemoveZerosInLeft

func ReturnsTheRows

func ReturnsTheRows(text string) []string

ReturnsTheRows o antigo nome era: RetornaAsLinhas

func StandardizesMasksByCard

func StandardizesMasksByCard(numeroCartao string) string

StandardizesMasksByCard o antigo nome era: PadronizaMascarasDeCartao

func StringTrim

func StringTrim(value string) string

StringTrim

func Subtract

func Subtract(valo1, valor2 float64) float64

Subtract

func Throw

func Throw(up Exception)

Throw

func ToComparePassword added in v1.5.0

func ToComparePassword(password1, password2 string) error

Comparing the password with the hash

func TokenGeneratorMessageId

func TokenGeneratorMessageId() string

TokenGeneratorMessageId get token do Message.

func TokenGeneratorNLength

func TokenGeneratorNLength(length int) string

TokenGeneratorNLength o antigo nome era: RandToken

func TokenGeneratorOrderReferenceId

func TokenGeneratorOrderReferenceId() string

TokenGeneratorOrderReferenceId

func UpdloadInS3 added in v1.8.0

func UpdloadInS3(file multipart.File, path, fileName string) string

func UpdloadInS3Base64 added in v1.16.5

func UpdloadInS3Base64(b64 string, path, fileName string) string

func UpdloadInS3Base64Byte added in v1.16.6

func UpdloadInS3Base64Byte(b64 []byte, path, fileName string) string

func ValidateIfNotEmptyDate

func ValidateIfNotEmptyDate(data string) string

ValidateIfNotEmptyDate o antigo nome era: ValidaData

func ValidateIfNotEmptyNumber

func ValidateIfNotEmptyNumber(valor string) string

ValidateIfNotEmptyNumber o antigo nome era: ValidaDecimal

func ValidateTelephone

func ValidateTelephone(telefone string) string

ValidateTelephone o antigo nome era: ValidarTelefone

func ValidationCNPJ

func ValidationCNPJ(cnpj string) error

ValidationCNPJ o antigo nome era: ValidaCNPJ

func ValidationCPF

func ValidationCPF(cpf string) error

ValidationCPF o antigo nome era: ValidaCPF

func WeekEndDate added in v1.10.0

func WeekEndDate(date time.Time) time.Time

Qual é o dia da Sexta-feira da data que passou

func WeekStartDate added in v1.10.0

func WeekStartDate(date time.Time) time.Time

Qual é o dia da Segunda-feira da data que passou

func ZipFiles added in v1.11.0

func ZipFiles(filename string, files []string) error

Tutorial: https://golangcode.com/create-zip-files-in-go/

ZipFiles compresses one or many files into a single zip archive file.

Param 1: filename is the output zip file's name.
Param 2: files is a list of files to add to the zip.

Types

type Block

type Block struct {
	Try     func()
	Catch   func(Exception)
	Finally func()
}

func (Block) Do

func (tcf Block) Do()

Do

type Exception

type Exception interface{}

type KeepZero added in v1.7.1

type KeepZero float64

func (KeepZero) MarshalJSON added in v1.7.1

func (f KeepZero) MarshalJSON() ([]byte, error)

type Message added in v1.19.2

type Message struct {
	Log     *log.Logger
	File    string
	Query   string
	Info    string
	Error   string
	Objects interface{}
}

func FormatMessage added in v1.19.0

func FormatMessage(message Message) Message

type MongoObject2 added in v1.13.0

type MongoObject2 struct {
	Date   time.Time
	Object interface{}
}

Jump to

Keyboard shortcuts

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