Documentation
¶
Index ¶
- Variables
- func ArrayEqual[T any](arr1 []T, arr2 []T, ignoreLength ...bool) bool
- func CloneBytes(b []byte) []byte
- 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 SysFreeMemory() float64
- 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 Hashable
- type NullType
- type SupportedType
- type ToInterface
Constants ¶
This section is empty.
Variables ¶
var Clean *clean = &clean{}
var Conv *typeConv = &typeConv{}
var HTML *encodeHtml = &encodeHtml{}
var JSON *encodeJson = &encodeJson{}
var VarType map[string]reflect.Type
Functions ¶
func ArrayEqual ¶
ArrayEqual returns true if 2 arrays are equal and of the same length (even if they are in a different order)
func CloneBytes ¶ added in v7.5.3
CloneBytes is a simple method for copying a stuborn []byte that wants to be a reference
golang default: buf := make([]byte, 5) buf = []byte{'t', 'e', 's', 't', '1'} newBuf := buf newBuf[4] = 2 string(buf) == string(newBuf) using this method: buf := make([]byte, 5) buf = []byte{'t', 'e', 's', 't', '1'} newBuf := goutil.CloneBytes(buf) newBuf[4] = 2 string(buf) != string(newBuf)
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 ¶
MapEqual returns true if 2 maps are equal and of the same length (even if they are in a different order)
func SysFreeMemory ¶ added in v7.5.1
func SysFreeMemory() float64
SysFreeMemory returns the amount of memory available in megabytes
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 ¶
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 ¶
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 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{}
}