util

package
v0.0.0-...-3f9ec74 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 37 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BarcodeDv

func BarcodeDv(valueSequence string) string

BarcodeDv calculate DV from barcode

func Base64

func Base64(s string) string

Base64 converte um string para base64

func Base64Decode

func Base64Decode(s string) string

Base64Decode converte uma string base64 para uma string normal

func BrNow

func BrNow() time.Time

func BuildTLSTransport

func BuildTLSTransport(con certificate.TLSCertificate) (*http.Transport, error)

BuildTLSTransport creates a TLS Client Transport from crt, ca and key files

func CheckErrorRobot

func CheckErrorRobot(err error) bool

func Decrypt

func Decrypt(s string) string

Decrypt decripta string encriptada

func DefaultHTTPClient

func DefaultHTTPClient() *http.Client

DefaultHTTPClient retorna um cliente http configurado para dar um skip na validação do certificado digital

func Duration

func Duration(callback func()) (duration time.Duration)

func Encrypt

func Encrypt(s string) string

Encrypt encripta texto baseado na documentação do GO

func FromJSON

func FromJSON(jsonStr string, obj interface{}) error

FromJSON converts string json to object

func GetDurationTimeoutRequest

func GetDurationTimeoutRequest(t string) time.Duration

func GetFont

func GetFont() font

func GetTLSVersion

func GetTLSVersion(version string) uint16

func HeaderToMap

func HeaderToMap(header http.Header) map[string]string

HeaderToMap converte um http Header para um dicionário string -> string

func IsBasicCharacter

func IsBasicCharacter(r rune) bool

IsBasicCharacter Verifica se um caracter é uma letra sem acento, maiúscula ou minúscula, de acordo com o código decimal da Tabela ASCII onde o 'A' representa o valor 65 e o 'Z' o valor 90 e o 'a' representa o valor 97 e 'z' o valor 122 true para 0123456789

func IsCaixaSpecialCharacter

func IsCaixaSpecialCharacter(r rune) bool

IsCaixaSpecialCharacter Verifica se um caracter especial é aceito Caixa Econômica, de acordo com o código decimal da Tabela ASCII sendo aceito os seguinte caracteres:

esp	32	'	39   :	58
!	33	(	40   ;	59
		)	41   =	61
		*	42
		+	43   ?	63
		,	44
		-	45   _  95
		.	46
		/	47

OBS: Apesar de descritos como aceitos, os caracteres & (38) < (60) e > (62) foram removidos pois não estão disponíveis para XML. Testamos seus respectivos encodes: &amp; &lt; &gt; entretanto recebemos a resposta (66) CARACTER INVALIDO.

func IsDigit

func IsDigit(r rune) bool

IsDigit Verifica se um caracter é um dígito numérico de acordo com o código decimal da Tabela ASCII, onde o '0' representa o valor 48 e o '9' o valor 57

func LogConector

func LogConector(e *flow.ExchangeMessage, u flow.URI, params ...interface{}) error

LogConector é um connector flow para utilizar as rotinas de log

func MinifyString

func MinifyString(mString, tp string) string

MinifyString Minifica uma string de acordo com um determinado formato

func NycNow

func NycNow() time.Time

func OurNumberDv

func OurNumberDv(valueSequence string, modFunc ModFunc, base ...int) string

OurNumberDv calculate DV from OurNumber

func PadLeft

func PadLeft(value, char string, total uint) string

PadLeft insere um caractere a esquerda de um texto

func ParseJSON

func ParseJSON(s string, o interface{}) interface{}

ParseJSON converte string para um objeto GO

func Post

func Post(url, body, timeout string, header map[string]string) (string, int, error)

Post faz um requisição POST para uma URL e retorna o response, status e erro

func PostReponseWithHeader

func PostReponseWithHeader(url, body, timeout string, header map[string]string) (string, string, int, error)

Post faz um requisição POST para uma URL e retorna o response, status e erro

func PostTLS

func PostTLS(url, body, timeout string, header map[string]string, transport *http.Transport) (string, int, error)

func PostTLSWithHeader

func PostTLSWithHeader(url, body, timeout string, header map[string]string, transport *http.Transport) (string, map[string]interface{}, int, error)

func PostWithHeader

func PostWithHeader(url, body, timeout string, header map[string]string) (string, map[string]interface{}, int, error)

PostWithHeader faz um requisição POST para uma URL e retorna o response, status e erro

func SanitizeBody

func SanitizeBody(body string) string

Remove o caractete \t de uma string

func Sha256

func Sha256(s, e string) string

Sha256 converts string to hash sha256. Encode default: Base64

func SignRequest

func SignRequest(request string) (string, error)

Sign request

func Stringify

func Stringify(o interface{}) string

Stringify convete objeto para JSON

func TimeToLocalTime

func TimeToLocalTime(t time.Time) time.Time

func TlsConector

func TlsConector(e *flow.ExchangeMessage, u flow.URI, params ...interface{}) error

TlsConector is a connector to send https request client certificate Params[0] *http.Transport (http.Transport configuration with certificate files config)

func ToJSON

func ToJSON(obj interface{}) string

ToJSON converts object to json string

Types

type HTTPClient

type HTTPClient struct{}

HTTPClient is the struct for making requests

func (*HTTPClient) PostFormURLEncoded

func (hc *HTTPClient) PostFormURLEncoded(endpoint string, params map[string]string, log *log.Log) ([]byte, error)

PostFormEncoded is a function for making requests using Post Http method with content-type application/x-www-form-urlencoded.

It receives an endpoint, params and pointer for log and it creates a new Post request, returning []byte and a error.

type HTTPInterface

type HTTPInterface interface {
	Post(url string, headers map[string]string, body interface{}) (*http.Response, error)
}

HTTPInterface is an abstraction for HTTP client

type Mask

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

func NewMask

func NewMask(log *log.Log, messageType string) *Mask

func (*Mask) MaskJsonContentFields

func (mask *Mask) MaskJsonContentFields(content string) string

func (*Mask) MaskQueryParamsContentFields

func (mask *Mask) MaskQueryParamsContentFields(content string) string

func (*Mask) MaskXMLContentFields

func (mask *Mask) MaskXMLContentFields(content string) string

type ModFunc

type ModFunc int
const (
	MOD10 ModFunc = 1 + iota
	MOD11
)

Jump to

Keyboard shortcuts

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