modulepackage
0.0.0-20201010064512-ade9fc0d65ef
Repository: https://github.com/mdgsf/utils.git
Documentation: pkg.go.dev
# README
golang utility
golang test
go test
go test -v
go test -v hello_test.go
go test -v -test.run TestAgent
go test -cover -coverprofile=cover.out
go tool cover -html=cover.out -o coverage.html
go test -bench=. -run=none -benchmem
go test ./... -cover -coverprofile=cover.out -coverpkg=github.com/hujia-team/annotations_tool,github.com/hujia-team/annotations_tool/modules/dbm
运行当前目录,包括子目录中的所有测试文件
go test ./...
This should run all tests with import path prefixed with `foo/`:
go test foo/...
例子:
go test github.com/hujia-team/annotations_tool/...
运行包 github.com/hujia-team/annotations_tool 下面,包括子目录的所有测试文件
buffer reader
bytes.Buffer()
bytes.NewReader()
bufio.NewReader()
seperator in code
// ---------------------------------------------------
# Packages
Package cache provide a Cache interface and some implement engine Usage:
import( "github.com/astaxie/beego/cache" )
bm, err := cache.NewCache("memory", `{"interval":60}`)
Use it like this:
bm.Put("astaxie", 1, 10 * time.Second) bm.Get("astaxie") bm.IsExist("astaxie") bm.Delete("astaxie")
more docs http://beego.me/docs/module/cache.md.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Package log implements a simple logging package.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Functions
AfterSeconds return secs seconds from now.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
BytesToInt32 change byte array to int.
CopyMap copy src to dest.
CutMsgWithTemplate 根据 tpl 从 msg 中取出数据,放到 result 中.
FileExists judge whether file or directory exists.
GetRandomBytes generate random byte slice @param n[in]: the length of random string.
GetRandomString generate random string @param n[in]: the length of random string.
Int32Distinct get distinct elements from intList.
Int32ListEqual judge list a is equal to list b.
Int32ListRemove remove element in intList.
Int64ToString convert int64 to string.
IntTo4Bytes change int to 4 bytes.
IntToString change int to string.
IsDir check path is directory or not.
IsFile check path is file or not.
IsStringInArray is str in array.
IsStringWildCardMatchArray 在数组 array 中查找字符串 s,用通配符匹配。.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
MakeTimeFromMicroSeconds construct one time.Time from micro second.
MakeTimeFromMilliSeconds construct one time.Time from milli second.
MakeTimeFromNanoSeconds construct one time.Time from nano second.
MakeTimeFromSeconds construct one time.Time from second.
No description provided by the author
No description provided by the author
NewLeakyBuf creates a leaky buffer which can hold at most n buffer, each with bufSize bytes.
NewRandString generate random string.
ObjectToJSONBuffer json marshal.
PackUint32BE pack uint32 to []byte, in big endian.
PackUint32LE pack uint32 to []byte, in little endian.
PathExists judge whether file or directory exists.
SelfDir gets compiled executable file directory.
SelfPath gets compiled executable file absolute path.
StringToFloat32 convert string to float32.
StringToFloat64 convert string to float64.
StringToInt change string to int.
StringToInt64 convert string to int64.
StringToUint32 convert string to uint32.
StringToUint64 convert string to uint64.
TimeNowMicroSecond now microsecond.
TimeNowMilliSecond now millisecond.
TimeNowNonoSecond now nanosecond.
TimeNowSecond now second.
ToInt change interface to number.
ToInt64 change interface to int64.
Uint64ToString convert uint64 to string.
UnpackUint32BE unpack []byte to uint32, in big endian.
UnpackUint32LE unpack []byte to uint32, in little endian.
No description provided by the author
WildCardMatch 通配符匹配字符串
?: 匹配 0 个或者 1 个字符
*: 匹配 0 个,1 个或者任意多个字符
+: 匹配 1 个字符或者任意个字符,也就是至少 1 个字符
WildCardMatch("a?c", "abc") == true
WildCardMatch("a?c", "ac") == true
WildCardMatch("a*c", "ac") == true
WildCardMatch("a*c", "abc") == true
WildCardMatch("a*c", "abbbc") == true
WildCardMatch("a+c", "ac") == false
WildCardMatch("a+c", "abc") == true
WildCardMatch("a+c", "abbbc") == true
*/.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author