Documentation ¶
Overview ¶
Copyright (C) 2019 tisnyo <tisnyo@gmail.com>.
This file contains some common functions.
Copyright (C) 2019 tisnyo <tisnyo@gmail.com>.
This file provides some functions about time operation.
Copyright (C) 2019 tisnyo <tisnyo@gmail.com>.
This file simulate try-catch structure.
Index ¶
- func BlockTest()
- func CreateTime(millis int64) time.Time
- func GetDateString(t time.Time) string
- func GetDay(t time.Time) int
- func GetHour(t time.Time) int
- func GetHumanReadableDuration(start time.Time, end time.Time) string
- func GetLongDateString(t time.Time) string
- func GetLongHumanReadableDuration(start time.Time, end time.Time) string
- func GetLongLongDateString(t time.Time) string
- func GetMillionSecond(t time.Time) int
- func GetMinute(t time.Time) int
- func GetMonth(t time.Time) int
- func GetMyAddress(preferredNetworks ...string) string
- func GetNanosecond(t time.Time) int64
- func GetSecond(t time.Time) int
- func GetShortDateString(t time.Time) string
- func GetTimestamp(t time.Time) int64
- func GetYear(t time.Time) int
- func LimitRange(value interface{}, defaultValue interface{}, rangeValues ...interface{}) interface{}
- func List2Array(ls *list.List) []interface{}
- func Md5Sum(input ...string) string
- func ParseHostPortFromConnStr(connStr string) (string, int)
- func TOperation(condition bool, trueOperation func() interface{}, ...) interface{}
- func TValue(condition bool, trueValue interface{}, falseValue interface{}) interface{}
- func Try(f func(), catcher func(e interface{}))
- func WalkList(ls *list.List, walker func(item interface{}) bool)
- type IP
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTime ¶
CreateTime returns the local Time corresponding to the given Unix time, sec seconds and nsec nanoseconds since January 1, 1970 UTC. It is valid to pass nsec outside the range [0, 999999999]. Not all sec values have a corresponding time value. One such value is 1<<63-1 (the largest int64 value).
func GetDateString ¶
GetDateString gets short date format like '2018-11-11'.
func GetHumanReadableDuration ¶
GetHumanReadableDuration gets a duration between times and returns format like '01:12:31' (?hour:?minute:?second).
func GetLongDateString ¶
GetLongDateString gets date format like '2018-11-11 12:12:12'.
func GetLongHumanReadableDuration ¶
GetLongHumanReadableDuration gets a duration between times and returns format like '1d 3h 12m 11s' (?day ?hour ?minute ?second).
func GetLongLongDateString ¶
GetLongLongDateString gets short date format like '2018-11-11 12:12:12,233'.
func GetMillionSecond ¶
GetMillionSecond gets millionSecond number.
func GetMyAddress ¶
GetPreferredIPAddress get self ip address by preferred interface
func GetNanosecond ¶
GetNanosecond gets current timestamp in Nanosecond.
func GetShortDateString ¶
GetShortDateString gets time format like '12:12:12'.
func GetTimestamp ¶
GetTimestamp gets current timestamp in milliseconds.
func LimitRange ¶
func LimitRange(value interface{}, defaultValue interface{}, rangeValues ...interface{}) interface{}
LimitRange limits a variable's value in a value range. returns defaultValue if the range not provided or the value is not in the range,
func ParseHostPortFromConnStr ¶
ParseHostPortFromConnStr parses host and port from connection string.
func TOperation ¶
func TOperation(condition bool, trueOperation func() interface{}, falseOperation func() interface{}) interface{}
TOperation simulates ternary operation.
Types ¶
Directories ¶
Path | Synopsis |
---|---|
hash
|
|
hashcode
see https://steveperkins.com/go-java-programmers-simple-types/
|
see https://steveperkins.com/go-java-programmers-simple-types/ |
hashmap
hashmap比golang内置的map添加速度要快,1000w数据hashmap比内置map快几百毫秒-1秒 删除速度也较快 内存占用由于hashmap实现的原因,在接近2^n但不到2^n时,hashmap占用空间较小,当hashmap扩容时(此时元素刚刚超过2^n,但是容量翻翻),hashmap会比内置map占用内存大。
|
hashmap比golang内置的map添加速度要快,1000w数据hashmap比内置map快几百毫秒-1秒 删除速度也较快 内存占用由于hashmap实现的原因,在接近2^n但不到2^n时,hashmap占用空间较小,当hashmap扩容时(此时元素刚刚超过2^n,但是容量翻翻),hashmap会比内置map占用内存大。 |
gifx
package gifx.
|
package gifx. |