Documentation
¶
Index ¶
- Variables
- 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 ToType[T SupportedType](val interface{}) T
- func TrimRepeats(b []byte, chars []byte) []byte
- 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 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 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 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{}
}