import (
uf "github.com/ac5tin/usefulgo"
)
// ArrContains check is array contains a string
containstring := uf .ArrContains (arrstring ,str )
// ArrRMS removes string element from array (ordered)
uf .ArrRMS (& arr ,str )
ArrRMiF and ArrRmiS (remove array elemet by index (fast and slow))
ArrRmiF (Fast array index remover but doesnt maintain order)
ArrRmiS (Slow array index remover but maintains order)
NewArrRmiF ().String (& stringarr ,3 )
NewArrRmiS ().Int (& intarr ,3 )
// GetBytes returns binary byte slices
byteslices ,err := uf .GetBytes (x )
// CSVParser parses csv and runs callback function
reader := bytes .NewReader (byteslice )
r := csv .NewReader (reader )
err := uf .CSVParser (r ,func (res []string ,chunk int ){
})
// // CSVParserH parses csv with headers and runs callback function
reader := bytes .NewReader (byteslice )
r := csv .NewReader (reader )
err := uf .CSVParserH (r ,func (res []map [string ]string ,chunk int ){
})
// HashPassword returns hashed version of password
hashed ,err := uf .HashPassword (pw ,cost )
// CheckPasswordHash compares hashes between password string
cmp := uf .CheckPasswordHash (pw ,hashed )
// Mapfields - returns subset map
mf := uf .Mapfields (d , fields ) //d is of type map[string]interface{}
// Hashmap hashes a map using sha256 and returns the hash as string
mfhash , err := uf .Hashmap (mf )
// RandString generates random string
rnd := uf .RandString (5 )
// RmDash removes dashes from strings
newstr := uf .RmDash (oldstr )
x := - 5
absx := uf .IntAbs (x ) // returns 5
NewCmpr ().Compress (data ,"xz" ) // gz for gzip, xz for LZMA2 xz
NewCmpr ().Decompress (data ,"xz" )
NumParse [int64 ]("123" ) // parse string to int64
FloatParse [float32 ]("1.12" ) // parse string to float32