Documentation ¶
Index ¶
- Variables
- func ArrayEqual[T any](arr1 []T, arr2 []T, ignoreLength ...bool) bool
- func Contains[T any](search []T, value T) bool
- func ContainsMap[T Hashable, J any](search map[T]J, value J) bool
- func ContainsMapKey[T Hashable, J any](search map[T]J, key T) bool
- func FormatMemoryUsage(b uint64) float64
- func IndexOf[T any](search []T, value T) (int, error)
- func IndexOfMap[T Hashable, J any](search map[T]J, value J) (T, error)
- func IsZeroOfUnderlyingType(x interface{}) bool
- func MapArgs(args ...[]string) map[string]string
- func MapArgsByte(args ...[][]byte) map[string][]byte
- func MapEqual[T Hashable, J any](map1 map[T]J, map2 map[T]J, ignoreLength ...bool) bool
- func ToType[T SupportedType](val interface{}) T
- func ToVarType[T SupportedType](val interface{}, ref T) T
- func ToVarTypeInterface(val interface{}, ref interface{}) interface{}
- func TrimRepeats(b []byte, chars []byte) []byte
- func TypeEqual(val1 interface{}, val2 interface{}) bool
- type FileWatcher
- type Hashable
- type LinuxPKG
- type NullType
- type SupportedType
- type ToInterface
Constants ¶
This section is empty.
Variables ¶
var BROTLI *compBrotli = &compBrotli{}
var Clean *clean = &clean{}
var Conv *typeConv = &typeConv{}
var Crypt *crypt = &crypt{
cryptCFB{},
cryptHash{},
}
Encryption
var FS *fileSystem = &fileSystem{}
var GZIP *compGzip = &compGzip{}
var HTML *encodeHtml = &encodeHtml{}
var JSON *encodeJson = &encodeJson{}
var SMAZ *compSmaz = &compSmaz{}
var VarType map[string]reflect.Type
Functions ¶
func ArrayEqual ¶ added in v5.1.0
ArrayEqual returns true if 2 arrays are equal and of the same length (even if they are in a different order)
func ContainsMap ¶
ContainsMap returns true if a map contains a value
func ContainsMapKey ¶
ContainsMapKey returns true if a map contains a key
func FormatMemoryUsage ¶
FormatMemoryUsage converts bytes to megabytes
func IndexOf ¶
IndexOf returns the index of a value in an array
returns -1 and an error if the value is not found
func IndexOfMap ¶
IndexOfMap returns the index of a value in a map
returns an error if the value is not found
func IsZeroOfUnderlyingType ¶
func IsZeroOfUnderlyingType(x interface{}) bool
IsZeroOfUnderlyingType can be used to determine if an interface{} in null or empty
func MapArgs ¶
MapArgs will convert a bash argument array ([]string) into a map (map[string]string)
When @args is left blank with no values, it will default to os.Args[1:]
-- Arg Convertions:
"--Key=value" will convert to "key:value"
"--boolKey" will convert to "boolKey:true"
"-flags" will convert to "f:true, l:true, a:true, g:true, s:true" (only if its alphanumeric [A-Za-z0-9]) if -flags is not alphanumeric (example: "-test.paniconexit0" "-test.timeout=10m0s") it will be treated as a --flag (--key=value --boolKey)
keys that match a number ("--1" or "-1") will start with a "-" ("--1=value" -> "-1:value", "-1" -> -1:true) this prevents a number key from conflicting with an index key
everything else is given a number value index starting with 0
this method will not allow --args to have their values modified after they have already been set
func MapArgsByte ¶
MapArgs is just like MapArgs, but it excepts and outputs using []byte instead of string
func MapEqual ¶ added in v5.1.0
MapEqual returns true if 2 maps are equal and of the same length (even if they are in a different order)
func ToType ¶
func ToType[T SupportedType](val interface{}) T
ToType attempts to converts an interface{} from the many possible types in golang, to a specific type of your choice
if it fails to convert, it will return a nil/zero value for the appropriate type
func ToVarType ¶ added in v5.1.0
func ToVarType[T SupportedType](val interface{}, ref T) T
ToVarType grabs the type from another var as a reference, and runs the `ToType` with the ref type
func ToVarTypeInterface ¶ added in v5.1.0
func ToVarTypeInterface(val interface{}, ref interface{}) interface{}
ToVarTypeInterface attempts to convert an interface to match the unknown type of another interface
this method is similar to the ToType method, but it simply returns nil if it cannot find the proper var type
func TrimRepeats ¶
TrimRepeats trims repeating adjacent characters and reduces them to one character
@b: byte array to trim
@chars: list of bytes to trim repeats of
Types ¶
type FileWatcher ¶
type FileWatcher struct { // when a file changes // // @path: the file path the change happened to // // @op: the change operation OnFileChange func(path string, op string) // when a directory is added // // @path: the file path the change happened to // // @op: the change operation // // return false to prevent that directory from being watched OnDirAdd func(path string, op string) (addWatcher bool) // when a file or directory is removed // // @path: the file path the change happened to // // @op: the change operation // // return false to prevent that directory from no longer being watched OnRemove func(path string, op string) (removeWatcher bool) // every time something happenes // // @path: the file path the change happened to // // @op: the change operation OnAny func(path string, op string) // contains filtered or unexported fields }
A watcher instance for the `FS.FileWatcher` method
func (*FileWatcher) CloseWatcher ¶
func (fw *FileWatcher) CloseWatcher(root string) error
CloseWatcher will close the watcher by the root name you used
@root pass a file path for a specific watcher or "*" for all watchers that exist
func (*FileWatcher) WatchDir ¶
func (fw *FileWatcher) WatchDir(root string) error
WatchDir watches the files in a directory and its subdirectories for changes
type LinuxPKG ¶
type LinuxPKG struct {
// contains filtered or unexported fields
}
linux package installer
func (*LinuxPKG) GetLinuxInstaller ¶
GetLinuxInstaller attempt to find out what package manager a linux distro is using or has available
func (*LinuxPKG) HasLinuxPkg ¶
HasLinuxPkg attempt to check if a linux package is installed
func (*LinuxPKG) InstallLinuxPkg ¶
InstallLinuxPkg attempts to install a linux package
this method will also resolve the sudo command and ask for a user password if needed
this method will not attempt to run an install, if it finds the package is already installed
type SupportedType ¶
type SupportedType interface { string | []byte | byte | bool | int | int64 | int32 | int16 | int8 | uint | uint64 | uint32 | uint16 | uintptr | float64 | float32 | []interface{} | []string | [][]byte | []bool | []int | []int64 | []int32 | []int16 | []int8 | []uint | []uint64 | []uint32 | []uint16 | []uintptr | []float64 | []float32 | map[string]interface{} | map[byte]interface{} | map[int]interface{} | map[int64]interface{} | map[int32]interface{} | map[int16]interface{} | map[int8]interface{} | map[uint]interface{} | map[uint64]interface{} | map[uint32]interface{} | map[uint16]interface{} | map[uintptr]interface{} | map[float64]interface{} | map[float32]interface{} }
SupportedType is an interface containing the types which are supported by the ToType method
type ToInterface ¶
type ToInterface struct {
Val interface{}
}