Skip to content

Latest commit

 

History

History
134 lines (87 loc) · 3.09 KB

README.en.md

File metadata and controls

134 lines (87 loc) · 3.09 KB

go-utils

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.

package

hstring

dispose string Example

import: import "github.com/hujingnb/go-utils/hstring"

function:

  • Reverse: reverse string
  • CamelToSnake
  • SnakeToCamel
  • ToString: change var to string
  • Pad: Pad a string to a certain length with another string
  • Join: Join array elements with a string

hhash

hash function. Example

import: import "github.com/hujingnb/go-utils/hhash"

function:

  • Md5By32: get MD5 Hash Generator 32 Characters
  • Md5By16: get MD5 Hash Generator 16 Characters
  • Sha1: get sha1
  • Sha256
  • Sha512
  • Crc32

harray

dispose array. Example

import: import "github.com/hujingnb/go-utils/harray"

function:

  • Chunk: Split an array into chunks
  • Shuffle: array shuffle
  • InArray: check item is in array
  • IndexOf: get item first index in array
  • Unique: Removes duplicate values from an array
  • Equal: check array is same
  • EqualIgnoreOrder: check array is same, ignore order
  • Intersect: get intersection of arrays
  • Diff: get difference of arrays
  • BinarySearch: binary search
  • GetSureRandArr: get sure rand array by same seed
  • Count: count value of array
  • Reverse: reverse array
  • sort:
    • SortBubble
    • SortInsert: insertion sort
    • SortSelect: selection sort
    • SortQuick: quick sort
    • SortMerge: merge sort
  • NewTopList: top n list

hmap

dispose map. Example

import: import "github.com/hujingnb/go-utils/hmap"

function:

  • IterateByOrder: iterate map by dict order
  • Equal: check map is equal

hstruct

dispose struct. Example

import: import "github.com/hujingnb/go-utils/hstruct"

function:

  • ToMap: change to map
  • Name: get struct name

hnumber

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

hsystem

system function. Example

import: import "github.com/hujingnb/go-utils/hsystem"

function:

  • PrintOutAndErrToFile: write stdout and stderr to file

hcommon

common function. Example

import: import "github.com/hujingnb/go-utils/hcommon"

function:

  • Copy: depth copy for all kind
  • GetContextKeys: get context value all key
  • CopyContextValue: copy a net context by all key value
  • ReadChannelList: read value for channel list

PR items

  1. please run all test function after change file. command: go test ./...
  2. all function should has test function
  3. all function should has example function in file example_test.go
  4. all public function should in README file