Documentation ¶
Index ¶
- Constants
- func BytesToString(b Bytes) string
- func DurationHuman(d time.Duration) string
- func Format(in, out interface{}) error
- func FormatINI(in, out interface{}) error
- func FormatJSON(in, out interface{}) error
- func FormatXML(in, out interface{}) error
- func FormatYAML(in, out interface{}) error
- func ParseConfigFile(v interface{}, file string) error
- func ParseConfigFiles(v interface{}, files ...string) error
- func Round(f float64, n int) float64
- func StringToBool(s string) (bool, error)
- func StringToFloat64(s string) (float64, error)
- func StringToInt(s string) (int, error)
- func StringToInt64(s string) (int64, error)
- func TimeFormat(str string) string
- func ToBool(v interface{}) (bool, error)
- func ToFloat64(v interface{}) (float64, error)
- func ToInt(v interface{}) (int, error)
- func ToInt64(v interface{}) (int64, error)
- func ToJSON(in interface{}) ([]byte, error)
- func ToString(v interface{}) (string, error)
- func ToXML(in interface{}) ([]byte, error)
- func ToYAML(in interface{}) ([]byte, error)
- type Bytes
- type CallFuncType
- type Configer
- type Float64
- type Formatter
- type HashMap
- type Int
- type Int64
- type IntList
- type Interface
- type List
- func (i List) Append(v ...interface{})
- func (i List) Contains(v interface{}) bool
- func (i List) Count(v interface{}) int
- func (i List) Index(v interface{}) int
- func (i List) Insert(id int, v interface{})
- func (i List) Len() int
- func (i List) List() []interface{}
- func (i List) Pop(id ...int) interface{}
- type Map
- type Result
- type SortMap
- type String
- type StringList
- func (s StringList) Append(v ...string)
- func (s StringList) Contains(v string) bool
- func (s StringList) Count(v string) int
- func (s StringList) Index(v string) int
- func (s StringList) Insert(idx int, v string)
- func (s StringList) Len() int
- func (s StringList) List() []string
- func (s StringList) Pop(idx ...int) string
- type Time
- type Typer
Constants ¶
const ( // B byte 8bit B = 1 // KB Kibibyte 2^10B KB = 1024 * B // MB Mebibyte 2^20B MB = 1024 * KB // GB Gigabyte 2^30B GB = 1024 * MB // TB Terabyte 2^40B TB = 1024 * GB // PB Petabyte 2^50B PB = 1024 * TB // EB Exabyte 2^60B EB = 1024 * PB )
const ( Second = int64(time.Second) Minute = int64(time.Minute) Hour = int64(time.Hour) Day = Hour * 24 Month = Day * 30 Year = Month * 12 )
time duration int64
Variables ¶
This section is empty.
Functions ¶
func BytesToString ¶
BytesToString byte => string 直接转换底层指针,两者指向的相同的内存,改一个另外一个也会变。 效率是string(Bytes{})的百倍以上,且转换量越大效率优势越明显。
func Format ¶
func Format(in, out interface{}) error
Format implement Formatter interface map[string]interface{} => struct{} eg: Format(map[string]interface{...}, &Struct{})
func ParseConfigFile ¶
ParseConfigFile parse config file
func ParseConfigFiles ¶
ParseConfigFiles parse config files
func StringToBool ¶
StringToBool string => bool, if fail return false
func StringToFloat64 ¶
StringToFloat64 string => float64, if fail return 0
func StringToInt ¶
StringToInt string => int, if fail return 0
func StringToInt64 ¶
StringToInt64 string => int64, if fail return 0
Types ¶
type Bytes ¶
type Bytes = []byte
Bytes equal []byte
func StringToBytes ¶
StringToBytes string => Bytes 直接转换底层指针,两者指向的相同的内存,改一个另外一个也会变。 效率是string(Bytes{})的百倍以上,且转换量越大效率优势越明显。 转换之后若没做其他操作直接改变里面的字符,则程序会崩溃。 如 b:=String2bytes("xxx"); b[1]='d'; 程序将panic。
type CallFuncType ¶
CallFuncType call func type
type IntList ¶
type IntList []int
IntList intList
type Interface ¶
type Interface struct {
// contains filtered or unexported fields
}
Interface interface field
type List ¶
type List []interface{}
List list
func CallFuncName ¶
CallFuncName call func name
func CallMethodName ¶
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>
func FuncWithTimeout ¶
FuncWithTimeout func timeout
func (List) Append ¶
func (i List) Append(v ...interface{})
Append L.append(object) -- append object to end
type Map ¶
type Map = map[string]interface{}
Map map
func BytesToMap ¶
BytesToMap []byte => map[string]interface{}
func StringToMap ¶
StringToMap string => map[string]interface{}
type StringList ¶
type StringList []string
StringList StringList
func (StringList) Append ¶
func (s StringList) Append(v ...string)
Append append to the end L.append(object) -- append object to end
func (StringList) Count ¶
func (s StringList) Count(v string) int
Count L.count(value) -> integer -- return number of occurrences of value
func (StringList) Pop ¶
func (s StringList) Pop(idx ...int) string
Pop 指定下标,删除指定的元素,如果删除一个不存在的元素会报错,默认Pop()删除最后一个元素