some common util method collection
if you has a question, but don't has. welcome commit issue
or PR
. please commit PR
to dev
branch.
install: go get github.com/hujingnb/go-utils
you can see document on godoc.
dispose string Example
import: import "github.com/hujingnb/go-utils/hstring"
function:
Reverse
: reverse stringCamelToSnake
SnakeToCamel
ToString
: change var to stringPad
: Pad a string to a certain length with another stringJoin
: Join array elements with a string
hash function. Example
import: import "github.com/hujingnb/go-utils/hhash"
function:
Md5By32
: get MD5 Hash Generator 32 CharactersMd5By16
: get MD5 Hash Generator 16 CharactersSha1
: get sha1Sha256
Sha512
Crc32
dispose array. Example
import: import "github.com/hujingnb/go-utils/harray"
function:
Chunk
: Split an array into chunksShuffle
: array shuffleInArray
: check item is in arrayIndexOf
: get item first index in arrayUnique
: Removes duplicate values from an arrayEqual
: check array is sameEqualIgnoreOrder
: check array is same, ignore orderIntersect
: get intersection of arraysDiff
: get difference of arraysBinarySearch
: binary searchGetSureRandArr
: get sure rand array by same seedCount
: count value of arrayReverse
: reverse array- sort:
SortBubble
SortInsert
: insertion sortSortSelect
: selection sortSortQuick
: quick sortSortMerge
: merge sort
NewTopList
: top n list
dispose map. Example
import: import "github.com/hujingnb/go-utils/hmap"
function:
IterateByOrder
: iterate map by dict orderEqual
: check map is equal
dispose struct. Example
import: import "github.com/hujingnb/go-utils/hstruct"
function:
ToMap
: change to mapName
: get struct name
dispose number. Example
import: import "github.com/hujingnb/go-utils/hnumber"
function:
HexInput
: read a string number on specify hex.HexOutput
: change a number to specify hex.RandRange
: get a int by range
system function. Example
import: import "github.com/hujingnb/go-utils/hsystem"
function:
PrintOutAndErrToFile
: write stdout and stderr to file
common function. Example
import: import "github.com/hujingnb/go-utils/hcommon"
function:
Copy
: depth copy for all kindGetContextKeys
: get context value all keyCopyContextValue
: copy a net context by all key valueReadChannelList
: read value for channel list
- please run all test function after change file. command:
go test ./...
- all function should has test function
- all function should has example function in file
example_test.go
- all public function should in
README
file