data

package
v0.0.0-...-9efb58e Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LetterIdxBits = 6                    // 6 bits to represent a letter index
	LetterIdxMask = 1<<LetterIdxBits - 1 // All 1-bits, as many as letterIdxBits
	LetterIdxMax  = 63 / LetterIdxBits   // # of letter indices fitting in 63 bits
)
View Source
const LetterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

Variables

View Source
var NonAlphanumericRegex = regexp.MustCompile(`[^a-zA-Z]+`)
View Source
var NonNumericRegex = regexp.MustCompile(`[^0-9]+`)
View Source
var RandSource = rand.NewSource(time.Now().UTC().UnixNano())

Functions

func AtInside

func AtInside(s []string, f string) (int, bool)

AtInside returns the index location where f string exists inside s slice of strings

func BB

func BB(s string) (b []byte)

func Base64

func Base64(in string) string

func Base64JSON

func Base64JSON(in map[string]string) string

func ChunkBy

func ChunkBy[T any](items []T, chunkSize int) (chunks [][]T)

func Cleanse

func Cleanse(in string) string

func CombineSlices

func CombineSlices(first []string, second []string) []string

func Contains

func Contains(s []string, e string) bool

func ContainsInt

func ContainsInt(s []int, e int) bool

func DuplicateString

func DuplicateString(s string, n int) string

func ExtractNumbers

func ExtractNumbers(str string) int

func Fib

func Fib() func() int

func HasNextIdx

func HasNextIdx(s []string, i int) bool

HasNextIdx is a wrapped safety check for a slice to ensure if an action is about to occur on an index, that the index exists first as a bool

func HasNumber

func HasNumber(str string) bool

func HumanReadableFileMode

func HumanReadableFileMode(fm fs.FileMode) (string, error)

func IsInside

func IsInside(s []string, e string) bool

IsInside acts like strings.Contains but lets you pass in a slice of strings instead of just a string

func IsYes

func IsYes(s string) bool

func KeepNumbers

func KeepNumbers(str string) string

func Max

func Max(x, y int) int

func MergeByteSlices

func MergeByteSlices(slices ...[]byte) []byte

func MergeStringSlices

func MergeStringSlices(slices ...[]string) []string

func PadNumber

func PadNumber(number string) string

func Prepend

func Prepend(existing []any, items ...any) (out []any)

func RandomBytes

func RandomBytes() []byte

func RandomInt

func RandomInt(limit int) int

RandomInt generates a cryptographically safe random integer

func RandomRangeInt

func RandomRangeInt(start int, limit int) int

RandomRangeInt return a random int that is between start and limit, will recursively run until match found

func RandomString

func RandomString(n int) string

func RemoveDirectorySlashes

func RemoveDirectorySlashes(directory string) string

func RemoveNumbers

func RemoveNumbers(str string) string

func ReplaceAllCaseInsensitive

func ReplaceAllCaseInsensitive(input, old, new string) string

func ReplaceIfInside

func ReplaceIfInside(insideThis []string, lookingAt string, replaceLookingForWith string) (string, bool)

ReplaceIfInside looks inside a slice of strings for a given string

func ReplaceInside

func ReplaceInside(s []string, f string, r string) ([]string, bool)

ReplaceInside searches for f inside s and replaces f with r and returns a modified s along with a bool if it worked

func ReplaceNonNumbers

func ReplaceNonNumbers(str string, repl string) string

func ReplaceNumbers

func ReplaceNumbers(str string, repl string) string

func ReverseString

func ReverseString(s string) string

func WrapText

func WrapText(text string, maxWidth int) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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