Documentation ¶
Index ¶
- Constants
- Variables
- func Announcement(message string) string
- func Center(str, padding string, width uint) string
- func CompactJSON(in string) string
- func Format(formatStr string, a ...interface{}) string
- func FrequencyDistributionScore(bs []byte) float64
- func GenerateSecureString(l int, dict string) (string, error)
- func IsInSlice(str string, list []string) bool
- func KLDivergence(p, q []float64) float64
- func Len(str string) int
- func MaskString(orig, mask string, revealLength, length int) string
- func PosInSlice(str string, list []string) int
- func PrettyJson(data interface{}) (string, error)
- func RandStringWithLengthLimit(n int) string
- func Reverse(s string) (result string)
- func Sha1(in string) string
- func Sha256(in string) string
- func Sha512(in string) string
- func StringBetween(str, start, end string) string
- func StringsBetween(str, start, end string) (between []string)
- func SubString(str string, startIndex, endIndex int) string
- func SubStringEnd(str string, endIndex int) string
- func SubStringStart(str string, startIndex int) string
- func ToCamel(s string) string
- func ToCamelLower(s string) string
- func ToOrdinise(number int) string
- func ToSnake(s string) string
- func ToSnakeUpper(s string) string
- func ToSpinal(s string) string
- func ToTrain(s string) string
- func Truncate(str string, length int, withExtenders bool) string
- func UUID4() (string, bool)
- type Formatter
- type Gen
- type UUID
Constants ¶
const ( // CharsNum contains numbers from 0-9 CharsNum = "0123456789" // CharsAlpha contains the full English alphabet: letters a-z and A-Z CharsAlpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" // CharsAlphaNum is a combination of CharsNum and CharsAlpha CharsAlphaNum = CharsNum + CharsAlpha // CharsASCII contains all printable ASCII characters in code range [32, 126] CharsASCII = CharsAlphaNum + " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" )
Variables ¶
var ( // ErrInvalidLengthSpecified is returned when the length specified is invalid ErrInvalidLengthSpecified = errors.New("invalid password length specified") // ErrInvalidDictSpecified is returned when the dictionary specified is invalid ErrInvalidDictSpecified = errors.New("invalid password dictionary specified") )
Functions ¶
func Announcement ¶
func CompactJSON ¶
func Format ¶
Given a string with brackets like "{} foo {}" and a number of inputs equivalent to the number of brackets in the string, like "too", "baz", this function will return a string such that an item is matched with its corresponding bracket. So the function stringit.Format("{} foo {}", "too", "baz") wil yield "too foo baz"
func FrequencyDistributionScore ¶
FrequencyDistributionScore computes a heuristic score for the frequency distribution of letters in bs, relative to masterFreq. It also applies some heurstics to determine if the text looks like English at all. The lower the score, the closer to English it looks.
func GenerateSecureString ¶
Generate generates a cryptographically secure and unbiased string of length 'l' using alphabet 'dict'
func KLDivergence ¶
func MaskString ¶
func PosInSlice ¶
func PrettyJson ¶
func StringBetween ¶
func StringsBetween ¶
func SubStringEnd ¶
func SubStringStart ¶
func ToCamelLower ¶
func ToOrdinise ¶
func ToSnakeUpper ¶
Types ¶
type Gen ¶
Gen is a version 4 UUID generator backed by a CSPRNG.
func UUIDNewGen ¶
func UUIDNewGen() *Gen
NewGen initializes and returns a new version 4 UUID generator.
type UUID ¶
type UUID [16]byte
UUID represents a UUID (any version). This is explicitly an array so that users can directly slice the binary representation.