modulepackage
0.0.0-20231030094300-cb028e65de09
Repository: https://github.com/ac5tin/usefulgo.git
Documentation: pkg.go.dev
# README
UsefulGo
Get Started
import (
uf "github.com/ac5tin/usefulgo"
)
Array
ArrContains
// ArrContains check is array contains a string
containstring := uf.ArrContains(arrstring,str)
ArrRMS
// 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)
Binary
GetBytes
// GetBytes returns binary byte slices
byteslices,err := uf.GetBytes(x)
CSV
CSVParser
// 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
// // 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){
})
Hash
HashPassword
// HashPassword returns hashed version of password
hashed,err := uf.HashPassword(pw,cost)
CheckPasswordHash
// CheckPasswordHash compares hashes between password string
cmp := uf.CheckPasswordHash(pw,hashed)
Mapfields
// Mapfields - returns subset map
mf := uf.Mapfields(d, fields) //d is of type map[string]interface{}
Hashmap
// Hashmap hashes a map using sha256 and returns the hash as string
mfhash, err := uf.Hashmap(mf)
Random
RandString
// RandString generates random string
rnd := uf.RandString(5)
String
RmDash
// RmDash removes dashes from strings
newstr := uf.RmDash(oldstr)
UUID
GenUUIDV4
uuid := uf.GenUUIDV4()
Math
IntAbs
x := -5
absx := uf.IntAbs(x) // returns 5
Compression
Compress, Decompress
NewCmpr().Compress(data,"xz") // gz for gzip, xz for LZMA2 xz
NewCmpr().Decompress(data,"xz")
Parsing
NumParse, FloatParse
NumParse[int64]("123") // parse string to int64
FloatParse[float32]("1.12") // parse string to float32
# Functions
No description provided by the author
ArrRM removes element from array (ordered).
ArrRmF removes element from array (unordered,fast).
ArrRmS removes element from array (ordered,slow).
CheckPasswordHash compares hashes between password string.
CSVParser parses csv and runs callback function.
CSVParserH parses csv with headers and runs callback function.
FloatParse parses a string to a float type.
GenUUIDV4 generates uuidv4 uuid.
GetBytes returns binary byte slices.
Hashmap hashes a map using sha256 and returns the hash as string.
HashPassword returns hashed version of password.
IntAbs - returns the absolute value of x.
Mapfields - returns subset map.
NewCmpr - create new compression.
NewCrypto - instantiate new Crypto.
NewFS - returns new FS.
NewMisc - create new misc.
NumParse parses a string to a number type.
RandString generates random string.
RmDash removes dashes from strings.
# Structs
Cmpr - compression.
Crypto - crypto library.
FS - filesystem.
Misc - misc.
URLBuilder - URL string builder.