Categorygithub.com/luopengift/types
modulepackage
0.0.0-20190129081739-38e990d849fc
Repository: https://github.com/luopengift/types.git
Documentation: pkg.go.dev

# README

Types Package

Build Status GoDoc GoWalker License

warp basic type for golang and offer some extra type transform functions

# Packages

No description provided by the author
No description provided by the author

# Functions

BytesToMap []byte => map[string]interface{}.
BytesToString byte => string 直接转换底层指针,两者指向的相同的内存,改一个另外一个也会变。 效率是string(Bytes{})的百倍以上,且转换量越大效率优势越明显。.
CallFuncName call func name.
CallMethodName Call method by name Example: type Test struct { i int j int } func (t *Test) Add(i int) (int,error) { return t.i+t.j+i, nil } var T = &Test{1,2} CallMethodName(T,"Add",1) // [4 <nil>] <nil>.
Clean 清理#注释.
DurationHuman duration human.
FileToBytes file => []byte.
FileToMap file => map[string]interface{}.
Format implement Formatter interface map[string]interface{} => struct{} eg: Format(map[string]interface{...}, &Struct{}).
FormatINI format ini.
FormatJSON format json.
FormatXML format xml.
FormatYAML format yaml.
FuncWithTimeout func timeout.
MapToBytes map[string]interface{} => []byte.
NewSortMap sortmap.
Now now.
ParseConfigFile parse config file.
ParseConfigFiles parse config files.
Round float64四舍五入,并取前几位.
StringToBool string => bool, if fail return false.
StringToBytes string => Bytes 直接转换底层指针,两者指向的相同的内存,改一个另外一个也会变。 效率是string(Bytes{})的百倍以上,且转换量越大效率优势越明显。 转换之后若没做其他操作直接改变里面的字符,则程序会崩溃。 如 b:=String2bytes("xxx"); b[1]='d'; 程序将panic。.
StringToFloat64 string => float64, if fail return 0.
StringToInt string => int, if fail return 0.
StringToInt64 string => int64, if fail return 0.
StringToMap string => map[string]interface{}.
TimeFormat time string.
ToBool interface => bool.
ToBytes interface => []byte.
ToFloat64 interface => float64.
ToInt interface => int.
ToInt64 interface => int64.
ToJSON to json.
ToList interface => []interface.
ToMap interface => map[string]interface{}.
ToString interface => string.
ToXML to json.
ToYAML 将结构体in转换成yml格式的字符串, 适用于配置文件落地.

# Constants

B byte 8bit.
time duration int64.
EB Exabyte 2^60B.
GB Gigabyte 2^30B.
time duration int64.
KB Kibibyte 2^10B.
MB Mebibyte 2^20B.
time duration int64.
time duration int64.
PB Petabyte 2^50B.
time duration int64.
TB Terabyte 2^40B.
time duration int64.

# Structs

Interface interface field.
Result result.
SortMap sort Map.

# Interfaces

Configer config interface.
Formatter interface.
Typer type interface.

# Type aliases

Bytes equal []byte.
CallFuncType call func type.
Float64 float64.
HashMap map.
Int int field.
Int64 int64 field.
IntList intList.
List list.
Map map.
String string.
StringList StringList.
Time time.