utils

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Color = struct {
	Black   string
	Blue    string
	Grey    string
	Red     string
	White   string
	Reset   string
	Reverse string
}{
	Black:   "\u001b[38;5;16m",
	Blue:    "\u001b[38;5;45m",
	Grey:    "\u001b[38;5;252m",
	Red:     "\u001b[38;5;42m",
	White:   "\u001b[38;5;255m",
	Reset:   "\u001b[0m",
	Reverse: "\u001b[7m",
}

Functions

func AddUnderscore

func AddUnderscore(str string) string

Add underscrore to a string until it reachs 15 length

func ArrayContains

func ArrayContains(slice []string, val string) bool

func CalculateTime

func CalculateTime(old, new time.Time) string

func ChangeCase

func ChangeCase(s string) string

func CheckAndFindAvailablePort

func CheckAndFindAvailablePort(hostAddress string) (string, error)

func CheckErr

func CheckErr(msg string, err error)

func ExtractHostPortFromURL

func ExtractHostPortFromURL(rawURL string) (string, int, error)

func ExtractTitle

func ExtractTitle(respByte []byte) (string, string)

func ExtractValueFromMap

func ExtractValueFromMap(d *map[string]any, givenKey string) (any, error)

func FindAndReplaceAll

func FindAndReplaceAll(value, search, replace string, regex bool) (string, error)

ReplaceString processes the input `value` string, replacing occurrences of `search` with `replace`. If `regex` is true, `search` is treated as a regular expression.

func FormatNumericID

func FormatNumericID(number float64, width int) string

func FormatStringID

func FormatStringID(str string, width int) string

func IsPortAvailable

func IsPortAvailable(host string) bool

func ParseDataFromFrontend

func ParseDataFromFrontend[T interface{}](results []interface{}) T

Parse Data From Frontend to Search

func ParseDatabaseName

func ParseDatabaseName(site string) string

func PrintAnyData

func PrintAnyData(m any) string

Return printmap

func PseudorandomString

func PseudorandomString(length int) string

PseudorandomString generates a pseudorandom string with the specified length.

The generated string matches [A-Za-z0-9]+ and it's transparent to URL-encoding.

For a cryptographically random string (but a little bit slower) use RandomString instead.

func PseudorandomStringWithAlphabet

func PseudorandomStringWithAlphabet(length int, alphabet string) string

PseudorandomStringWithAlphabet generates a pseudorandom string with the specified length and characters set.

For a cryptographically random (but a little bit slower) use RandomStringWithAlphabet instead.

func RandomString

func RandomString(length int) string

RandomString generates a cryptographically random string with the specified length.

The generated string matches [A-Za-z0-9]+ and it's transparent to URL-encoding.

func RandomStringWithAlphabet

func RandomStringWithAlphabet(length int, alphabet string) string

RandomStringWithAlphabet generates a cryptographically random string with the specified length and characters set.

It panics if for some reason rand.Int returns a non-nil error.

func ResponseToByte

func ResponseToByte(resp *http.Response) ([]byte, error)

func ResponseToString

func ResponseToString(resp *http.Response) (string, error)

func SmartSort

func SmartSort(s string) string

func StructToJsonTOMap

func StructToJsonTOMap(s any) (map[string]any, error)

func StructToMap

func StructToMap(s any, tag string) map[string]any

func StructToMapExtact

func StructToMapExtact(s any) map[string]any

Types

This section is empty.

Jump to

Keyboard shortcuts

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