goutils

package module
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: MIT, MIT Imports: 44 Imported by: 0

README

Module goutils

O "goutils" é uma biblioteca em Go, projetada para facilitar a vida dos desenvolvedores. Semelhante a um canivete suíço, esta ferramenta é equipada com uma variedade de métodos úteis, abrangendo diversas necessidades comuns na programação. Desde a manipulação de strings até operações mais complexas em estruturas de dados, "goutils" se torna um recurso indispensável para aqueles que desejam otimizar seu fluxo de trabalho. Sua flexibilidade e abrangência fazem desta lib uma das favoritas na comunidade Go, permitindo que desenvolvedores se concentrem em criar soluções eficientes, enquanto "goutils" cuida dos detalhes. Uma verdadeira mão na roda!

Instalacao

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

Contribuindo

Relatórios de bugs e solicitações de pull são bem-vindos no GitHub em https://github.com/armando-couto/goutils. Este projeto tem a intenção de ser um espaço seguro e acolhedor para colaboração, e espera-se que os colaboradores adiram ao code of conduct.

Licença

A gem está disponível como código aberto sob os termos da MIT License.

Código de Conduta

Todos que interagem nas bases de código, rastreadores de problemas, salas de chat e listas de e-mails do projeto Push::Notification::Firebase são esperados a seguir o código de conduta.

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"
	LAYOUTYYYYMMDDTHHMMSS           = "2006-01-02T15:04:05"
	LAYOUTYYYYMMDDTHHMMSSZONE       = "2006-01-02T15:04:05-07:00"
)

Variables

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

Functions

func AddFileToZip

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

func ConnectAws() *session.Session

func ConnectionBDFirebird

func ConnectionBDFirebird() *sql.DB

func ConnectionBDMySQL

func ConnectionBDMySQL() *sql.DB

ConnectionBDMySQL o antigo nome era: ConexaoBDMySQL

func ConnectionBDPostgreSQL

func ConnectionBDPostgreSQL(applicationName string) *sql.DB

Esse método retorna uma conexão que possa dar INSERT, UPDATE e DELETE. Podendo passar na variável host vários hosts, isso é muito bom para quando tem replicações, tipo assim:

host = "localhost;127.0.0.1"

func ConnectionBDPostgreSQLORM

func ConnectionBDPostgreSQLORM() (DB *gorm.DB)

ConnectionBDPostgreSQLORM o antigo nome era: ConexaoBDORM

func ConnectionBDPostgreSQLRead

func ConnectionBDPostgreSQLRead(applicationName string) *sql.DB

func ConnectionBDPostgreSQLWithSSL

func ConnectionBDPostgreSQLWithSSL() *sql.DB

func ConnectionMongoDB

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

func ConvertFloat64ToString4Decimal(value float64) string

ConvertFloat64ToString4Decimal

func ConvertFloatToBrMoneyString

func ConvertFloatToBrMoneyString(value float64) string

ConvertFloatToBrMoneyString

func ConvertFloatToFloatScale2

func ConvertFloatToFloatScale2(valor float64) float64

ConvertFloatToFloatScale2

func ConvertIntToString

func ConvertIntToString(value int) string

ConvertStringToInt

func ConvertPassword

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

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

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 ConvertStringToTimeLayoutYYYYMMDDTHHMMSS

func ConvertStringToTimeLayoutYYYYMMDDTHHMMSS(value string) time.Time

ConvertStringToTimeLayoutYYYYMMDDTHHMMSS

func ConvertStringToTimeLayoutYYYYMMDDTHHMMSSZONE

func ConvertStringToTimeLayoutYYYYMMDDTHHMMSSZONE(value string) time.Time

func ConvertStringToTimeLayoutYYYY_MM_DD

func ConvertStringToTimeLayoutYYYY_MM_DD(value string) time.Time

ConvertStringToTimeLayoutYYYY_MM_DD

func ConvertStringToTimeLayoutYYYY_MM_DDTHH_MM_SS

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_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 ConvertTimeToStringLayoutDDMMYYYY

func ConvertTimeToStringLayoutDDMMYYYY(date time.Time) string

func ConvertTimeToStringLayoutDD_MM_YYYY

func ConvertTimeToStringLayoutDD_MM_YYYY(date time.Time) string

ConvertTimeToStringLayoutDD_MM_YYYY

func ConvertTimeToStringLayoutMM_DD_YYYY_HH_MM

func ConvertTimeToStringLayoutMM_DD_YYYY_HH_MM(date time.Time) string

func ConvertTimeToStringLayoutYYYY_MM_DDTHH_MM_SS_000

func ConvertTimeToStringLayoutYYYY_MM_DDTHH_MM_SS_000(date time.Time) string

ConvertTimeToStringLayoutYYYY_MM_DDTHH_MM_SS_000

func ConvertTimeToStringLayout_YYYY_MM_DD

func ConvertTimeToStringLayout_YYYY_MM_DD(date time.Time) string

ConvertStringToTimeLayout_YYYY_MM_DD o antigo nome era: ConvertStringToTimeLAYOUT_YYYY_MM_DD

func ConvertToTimeLayout_YYYY_MM_DD_HH_MM_SS

func ConvertToTimeLayout_YYYY_MM_DD_HH_MM_SS(value string) time.Time

func ConvertkeepZeroToFloat64

func ConvertkeepZeroToFloat64(value KeepZero) float64

ConvertkeepZeroToFloat64

func ConvertkeepZeroToFloat64To4Decimal

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 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 EncodeToString

func EncodeToString(max int) string

func ExecuteService

func ExecuteService(serviceConfig *service.Config)

func ExpiryDate

func ExpiryDate(valor string) (string, string)

ExpiryDate o antigo nome era: ValidadeCartao

func GeneratePassword

func GeneratePassword(passwordLength, minNum, minUpperCase int) string
rand.Seed(time.Now().Unix())

Exemplo: GeneratePassword(32, 2, 2)

func GeneratePasswordCurrent

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 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

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

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

func UpdloadInS3ArqTxt

func UpdloadInS3ArqTxt(texto string, path, fileName string) string

func UpdloadInS3Base64

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

func UpdloadInS3Base64Byte

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

func UpdloadInS3NotTime

func UpdloadInS3NotTime(file multipart.File, 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

func WeekEndDate(date time.Time) time.Time

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

func WeekStartDate

func WeekStartDate(date time.Time) time.Time

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

func ZipFiles

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

type KeepZero float64

func (KeepZero) MarshalJSON

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

type Message

type Message struct {
	File    string
	Script  string
	Info    string
	Error   string
	Objects []interface{}
}

Jump to

Keyboard shortcuts

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