str

package
v0.0.0-...-b105b8e Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatCpf        string = "###.###.###-##"
	FormatCnpj       string = "##.###.###/####-##"
	FormatCreditCard string = "####.####.####.####"
	MaskCreditCard   string = "****.****.****-####"
)
View Source
const (
	RegexOnlyLetters = "[^A-Z]"
	RegexOnlyNumbers = "[^0-9]"
)

Variables

This section is empty.

Functions

func ContainLetters

func ContainLetters(v string) bool

ContainLetters verifica se a string passada contem letras entre os caracteres

func ContainNumber

func ContainNumber(v string) bool

ContainNumber verifica se uma string contem numeros

func ContainNumbers

func ContainNumbers(v string) bool

ContainNumbers verifica se a string passada contem numeros entre os caracteres

func ContainNumbersAndLetters

func ContainNumbersAndLetters(v string) (r bool)

ContainNumbersAndLetters verifica se a string passada contem letras e numeros ao mesmo tempo

func Contains

func Contains(v string, strs ...string) bool

Contains verifica se alguma das strings passada contem no primeiro parametro

func CutString

func CutString(str, initial, final string, n int) (strOut string)

CutString remove parte do texto de acordo com o inicio e fim da sequencia informados, retornando o texto atualizado

func ExtractValue

func ExtractValue(body string, key string) string

func Format

func Format(v, format string) (result string)

Format essa funcao tem como objetivo mascarar strings em um determinado formato, o caractere # será substituído pelo valor subsequente da string, o caractere * a funcao entende como uma mascara em si, ou seja, ela conta os caracteres

func GetDiff

func GetDiff(str1, str2 string) (strOut string)

GetDiff returns the differences between the two given strings

func GetFilenameFromPath

func GetFilenameFromPath(p string) string

GetFilenameFromPath return filename given the path(url or local path)

func GetFilenameWithoutExtension

func GetFilenameWithoutExtension(v string) string

GetFilenameWithoutExtension returns the filename without extension of given path

func GetLastCharacter

func GetLastCharacter(v string, count int) (r string)

GetLastCharacter retorna os ultimos x/count caracteres de uma string

func GetNotZeroValue

func GetNotZeroValue(p ...string) string

GetNotZeroValue dado um array de valores string, é retornado o que tem valor nao zerovalue

func GetPathFromFullFilename

func GetPathFromFullFilename(v string) string

GetPathFromFilename get only the path of the whole path passed by parameter, it returns path without filename

func GetStringBetween

func GetStringBetween(str, initial, final string, includeInitialAndFinal bool) (strOut string)

GetStringBetween retorna a string que está entre a string inicial e final passada como parametro, caso nao encontre, retorne uma string vazia

func GetStringBetweenAll

func GetStringBetweenAll(str, initial, final string, includeInitialAndFinal bool) (strOut string)

GetStringBetweenAll Returns all strings between the start and end strings

func GetUriFromUrl

func GetUriFromUrl(urlString string) string

GetUriFromUrl retorna uma URI dado uma URL

func IsInt

func IsInt(url string) bool

IsInt check if a string is a valid number

func IsOnlyNumbers

func IsOnlyNumbers(v string) bool

func IsUrl

func IsUrl(url string) bool

IsUrl check if the string is a valid url

func LowerNoSpaceNoAccent

func LowerNoSpaceNoAccent(v string) string

LowerNoSpaceNoAccent apply 3 steps over string, transform to lowercase, remove duplicate spaces and remove accents

func NoSpaceNoAccent

func NoSpaceNoAccent(v string) string

NoSpaceNoAccent remove all the spaces of the given string, begin, end and middle of the string

func OnlyNumbers

func OnlyNumbers(v string) string

OnlyNumbers returns only numbers given a string

func PointerToString

func PointerToString(str *string) string

PointerToString convert string pointer to string as Zero value if pointer is nil

func RandString

func RandString(n int, chars string) (r string)

RandString generate a random string Use the constants RandStringCharsOnlyNumbers, RandStringCharsOnlyLetters and RandStringCharsLettersAndNumbers to facilitate to pass the type of character you'd like to generate limit the number of characters at 250

func RemoveAccent

func RemoveAccent(v string) string

RemoveAccent remove all accents from given string

func RemoveExtraSpaces

func RemoveExtraSpaces(v string) string

RemoveExtraSpaces remove all duplicated spaces over whole string

func ReplaceAtIndex

func ReplaceAtIndex(in string, char rune, idx int) string

ReplaceAtIndex altera um caractere em uma string baseado no index da mesma

func ReplaceSpecialCharacters

func ReplaceSpecialCharacters(v ...string) (result string)
ReplaceSpecialCharacters substitui todos os caracteres especiais do primeiro parametro pelo valor informado no

segundo parametro. Se o segundo parametro nao for informado, os caracteres serão apenas removidos. A partir do terceiro parametro sao consideradas excessoes a regra caso necessario. Ex: ReplaceSpecialCharacters("_teste!") saida: teste ReplaceSpecialCharacters("_teste!", "@") saida: @teste@ ReplaceSpecialCharacters("_teste!", "@", "!") saida: @teste!

func StrPad

func StrPad(input string, padLength int, padString string, padType string) string

StrPad returns the input string padded on the left, right or both sides using padType to the specified padding length padLength.

Example: input := "Codes"; StrPad(input, 10, " ", "RIGHT") // produces "Codes " StrPad(input, 10, "-=", "LEFT") // produces "=-=-=Codes" StrPad(input, 10, "_", "BOTH") // produces "__Codes___" StrPad(input, 6, "___", "RIGHT") // produces "Codes_" StrPad(input, 3, "*", "RIGHT") // produces "Codes"

func StrPadRight

func StrPadRight(input string, padLength int, padString string) string

StrPadRight adicionar `padLength` quantidade de caracteres a direita de uma string

func StringInSlice

func StringInSlice(a string, list ...string) bool

StringInSlice check if certain string contain in slice

func StringPToUint

func StringPToUint(v *string) uint

StringPToUint convert string pointer to uint, returns zero if pointer is nil

func ToCamel

func ToCamel(v string) string

func ToLowerCamelCase

func ToLowerCamelCase(v string) (result string)

func ToSnakeCase

func ToSnakeCase(str string) string

func ToString

func ToString(str interface{}) string

func TrimAll

func TrimAll(v string) string

TrimAll remove todos os espacos em uma string

func UpperNoSpaceNoAccent

func UpperNoSpaceNoAccent(v string) string

UpperNoSpaceNoAccent apply 3 steps over string, transform to uppercase, remove duplicate spaces and remove accents

func Uuid

func Uuid() string

func WordCount

func WordCount(v string) int

WordCount return the number of the words that contains in string

Types

type RandStringChars

type RandStringChars string
const RandStringCharsAllLettersAndNumbers RandStringChars = `0123456789ABCDEFGHIJKLMNOPQRSTUVW` +
	`XYZabcdefghijklmnopqrstuvwxyz`
const RandStringCharsLettersAndNumbers RandStringChars = "abcdefghijklmnopqrstuvwxyz0123456789"
const RandStringCharsOnlyLetters RandStringChars = "abcdefghijklmnopqrstuvwxyz"
const RandStringCharsOnlyNumbers RandStringChars = "0123456789"

func (RandStringChars) String

func (r RandStringChars) String() string

Jump to

Keyboard shortcuts

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