goutils

package module
v1.27.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT, MIT Imports: 48 Imported by: 4

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 AddElementStringWithReference added in v1.26.11

func AddElementStringWithReference(slicePointer *[]string, element string)

Função para adicionar um elemento a uma slice apontada por um ponteiro

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(applicationName, sslMode string, readOnly bool) *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 ConnectionMongoDB added in v1.12.0

func ConnectionMongoDB() *mongo.Database

func ContainsInArray added in v1.26.4

func ContainsInArray[T comparable](array []T, target T) bool

Todos os tipos precisam ser comparaveis

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 ConvertDateToBrazilFormat added in v1.26.5

func ConvertDateToBrazilFormat(date any) (string, error)

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 ConvertStringToTimeLayoutYYYYMMDDTHHMMSS added in v1.23.3

func ConvertStringToTimeLayoutYYYYMMDDTHHMMSS(value string) time.Time

ConvertStringToTimeLayoutYYYYMMDDTHHMMSS

func ConvertStringToTimeLayoutYYYYMMDDTHHMMSSZONE added in v1.24.2

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 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_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 added in v1.25.0

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 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 ConvertTimeToStringLayout_YYYY_MM_DD added in v1.20.4

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

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

DatePlusTime

func DecodeBase64ToString

func DecodeBase64ToString(value string) string

DecodeBase64ToString

func DecreaseNHours added in v1.27.1

func DecreaseNHours(value string) string

ConvertStringToTimeLayoutHH_MM_SS

func DownloadFromS3NotPublic added in v1.26.5

func DownloadFromS3NotPublic(fileName, localFilePath string) error

func DownloadFromS3Public added in v1.26.5

func DownloadFromS3Public(fileName, localFilePath string) error

func EncodeStringToBase64

func EncodeStringToBase64(value string) string

EncodeStringToBase64

func EncodeToString added in v1.21.0

func EncodeToString(max int) string

func ExecuteService added in v1.23.1

func ExecuteService(serviceConfig *service.Config)

func ExpiryDate

func ExpiryDate(valor string) (string, string)

ExpiryDate o antigo nome era: ValidadeCartao

func GeneratePassword added in v1.22.0

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

Exemplo: GeneratePassword(32, 2, 2)

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 IsError

func IsError(err error) bool

IsError o antigo nome era: IsError

func IsInList added in v1.26.10

func IsInList(value string, list []string) bool

Função para verificar se uma string está na lista

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 NotInList added in v1.26.10

func NotInList(value string, list []string) bool

Função para verificar se uma string não está na lista

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 UpdloadInS3ArqTxt added in v1.21.1

func UpdloadInS3ArqTxt(texto string, 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 UpdloadInS3NotTime added in v1.19.20

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 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 Crypt added in v1.26.6

type Crypt struct {
	Key []byte
	Iv  []byte
}

Chave e IV devem ter tamanhos específicos para AES-256 (32 bytes para chave e 16 bytes para IV)

func (Crypt) Decrypt added in v1.26.6

func (crypt Crypt) Decrypt(encryptedData string) ([]byte, error)

func (Crypt) Encrypt added in v1.26.6

func (crypt Crypt) Encrypt(data []byte) (string, error)

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