Documentation
¶
Index ¶
- Constants
- Variables
- func Addslashes(str string) string
- func ArrayToSimple(data interface{}, key string) (res []string, err error)
- func AttachFileDirectory(fpath string) error
- func Bin2hex(raw string) string
- func BuildTimeInterval(start, end time.Time) []string
- func ByteFormat(i float64) string
- func CheckHexAndLength(v string, l int) bool
- func CheckHexValid(vs string) bool
- func CheckIntSliceEqual(x, y []int) bool
- func CheckMd5(v string) bool
- func CheckSha1(v string) bool
- func CheckSha256(v string) bool
- func CheckStringSliceEqual(x, y []string) bool
- func Chr(c rune) string
- func ColorDump(c *color.Color, vals ...interface{})
- func Computation(data interface{}, keyField, valueField string) (res map[string]string, err error)
- func CopyFileContents(src, dst string) (err error)
- func DataTrunKey(data interface{}, key string) (res map[string]interface{}, err error)
- func DataTrunMulti(data interface{}, key string) (res map[string][]interface{}, err error)
- func DebugTrace() []string
- func Dump(vals ...interface{})
- func EndIntSlice(arr []int) (res int)
- func EndStringSlice(arr []string) (res string)
- func ErrSlice2Err(es []error) error
- func FieldExists(fieldName string, ptr interface{}) bool
- func FileGet(filename string) ([][]byte, error)
- func FileSize(filename string) int64
- func FileStrings(filename string) ([]string, error)
- func FormatDateInt64(v int64) (string, error)
- func FormatDateString(unix string) (string, error)
- func Fstrtotime(dateStr string) (T time.Time, err error)
- func GbkToUtf8(v string) string
- func GetBeforeDayTimer(day int64) time.Time
- func GetDayTimer(day int64) time.Time
- func GetLocalHostIPv4() (string, error)
- func GetTodayTimer() time.Time
- func GetWhereCondition(kws map[string]interface{}) (s string)
- func GetYesterdayTimer() time.Time
- func Hash(v []byte) uint32
- func Hex2bin(raw string) string
- func HexDump(raw string) string
- func InArrayInts(a int, arr []int) bool
- func InStringArray(v string, arr []string) bool
- func IntersectKeys(s1, s2 []string) (s []string)
- func IsArray(value interface{}) bool
- func IsCanUtf8ToGbk(s string) bool
- func IsDomain(s string) bool
- func IsExist(filename string) bool
- func IsIp(s string) bool
- func IsPtr(value interface{}) bool
- func IsReadable(name string) bool
- func IsSetQueryFieldParentMd5(query *sj.Json) bool
- func IsSlice(v interface{}) bool
- func IsUtf8(s string) bool
- func IsWriteable(name string) bool
- func IssetSlice(val interface{}, key int) bool
- func JsonBytesLength(jsons []*sj.Json) int64
- func JsonDecode(j interface{}) string
- func JsonDecodes(js []*sj.Json) (arr []string)
- func JsonDump(v interface{}) string
- func JsonMerge(j1, j2 *sj.Json) *sj.Json
- func Md5(str string) string
- func Md5Bytes(v []byte) string
- func MemInfo() (ret string)
- func MethodExists(methodName string, ptr interface{}) bool
- func Microtime() (float64, int64)
- func MinInt(x, y int) int
- func MinInt64(x, y int64) int64
- func Ord(c string) []rune
- func P(vals ...interface{})
- func ParseHostFromUrl(address string) (string, error)
- func ParseStr(str string) url.Values
- func Rand(min, max int) int
- func RandGenerator(n int) int
- func Random() float64
- func RangeByte(start, end rune, step int) (arr []byte)
- func RangeInt(start, end, step int) (arr []int)
- func Round(value float64, precision int) (f float64)
- func SaveFile(path string, content []byte, bak bool) error
- func ShuffleInt(arr []int) []int
- func SliceChunk(data []string, chunkSize int) (divided [][]string)
- func SliceIntUnique(slice []int) []int
- func SliceStringDiff(arr1 []string, arrs ...[]string) (data []string)
- func SliceStringIntersect(a, b []string) []string
- func SliceStringMerge(a []string, b ...[]string) []string
- func SliceStringUnion(a []string, b ...[]string) []string
- func SliceStringUnique(slice []string) []string
- func SliceToStringSlice(v interface{}) (ret []string, err error)
- func SplitByChar(smart, spChar1, spChar2 string) (data []string)
- func SplitComma(path string) []string
- func SplitPath(path string) (dir, name, typename string)
- func Sql(w string, values ...interface{}) string
- func SqlWhere(w string, values ...interface{}) string
- func StrToInt32(str string) (int32, error)
- func StringToUnicode2(s string) string
- func Stripslashes(str string) string
- func Strtotime(format string, t time.Time) (T time.Time, err error)
- func Substr(str string, begin, length int) string
- func SubstrCount(s, v string) int
- func ToString(v interface{}) string
- func URLDecode(str string) (string, error)
- func URLEncode(str string) string
- func Ucfirst(str string) string
- func UnicodeToString(s string) string
- func Uniqid(prefix string) string
- func UniqueKeys(s1, s2 []string) (s []string)
- func Utf8ToGbk(v string) string
- func ValueFromPtr(field string, ptr interface{}) (interface{}, error)
- func VarDump(vals ...interface{})
- func ViperFile(filepath string) error
- type F
- type MemDefine
Constants ¶
const (
CAPTION_NUM = 50 //定义容量
)
支持以下4种类型:
ArrayToSimple([]*User , "Name") ArrayToSimple([]User , "Name") //需要注意map 是无序的 ArrayToSimple(map[interface{}]*User , "Name") ArrayToSimple(map[interface{}]User , "Name")
Variables ¶
var (
CONTINUE_ERR = errors.New("continue")
)
Functions ¶
func Addslashes ¶
Returns a string with backslashes added before characters that need to be escaped. These characters are:
single quote (') double quote (") backslash (\)
func ArrayToSimple ¶
func AttachFileDirectory ¶
func ByteFormat ¶
func CheckHexAndLength ¶
func CheckHexValid ¶
func ColorDump ¶
c := color.New(color.FgCyan).Add(color.Underline) c := color.New(color.FgCyan, color.Bold) https://github.com/fatih/color
func Computation ¶
存在覆盖的情况
func CopyFileContents ¶
func DataTrunKey ¶
DataTrunKey使用示例:
需要注意:
- map 是无序的 , 返回结果全部都是无序的
- 重复的key 会被覆盖,请尽量保证没有重复的key
示例:
DataTrunKey([]*User , "Name") DataTrunKey([]User , "Name") DataTrunKey(map[interface{}]*User , "Name") DataTrunKey(map[interface{}]User , "Name")
func DataTrunMulti ¶
func EndIntSlice ¶
func ErrSlice2Err ¶
func FieldExists ¶
检测字段是否存在 支持[private]字段检测 支持[public]字段检测
func FileStrings ¶
func FormatDateInt64 ¶
func FormatDateString ¶
func Fstrtotime ¶
示例: " 2018-03-01 " "2018-03-01 14:57:51"
func GetLocalHostIPv4 ¶
func GetWhereCondition ¶
map where condition to string
func InStringArray ¶
func IntersectKeys ¶
返回s1中每个元素 可以在s2中的检索到的值 eg : s1 = ["a" , "b" , "c"] ; s2 = ["a+t" , "b+t"] => ["a","b"]
func IsCanUtf8ToGbk ¶
IsCanUtf8ToGbk 可以针对一些unicode 转换后的内容进一步判断,是否还需要再做一次转换
func IsSetQueryFieldParentMd5 ¶
特殊逻辑, 用于检测proc_chain是否传入parent_md5
func IsSlice ¶
func IsSlice(v interface{}) bool
判断传入的元素是否是slice 支持检测 []string, []int , []int64 , []in32 , []interface{} , []float64 , []uint32 , []uint64 , ...
func MethodExists ¶
检测方法是否存在 不支持[private]方法检测 只支持[public]方法检测,私有方法无法检测出来
func SliceChunk ¶
func SliceIntUnique ¶
func SliceStringDiff ¶
diff slice Compares arr1 against one or more other arrays and returns the values in arr1 that are not present in any of the other arrays.
func SliceToStringSlice ¶
任意[]interface{}转换为[]string []string => []string []int => []string []interface{} => []string []int32 => []string []uint32 => []string []uint64 => []string []floag64 => []string ...
func SplitByChar ¶
字符串两个切割符号支持 使用示例: SplitByChar(str , "&&" , "||");
func SplitComma ¶
"'ipinfo'.*.info.'city'": 4, "'ipinfo'.*.info.city": 4, "ipinfo.*.info.city": 4, "ipinfo.'*'.info.city": 4, "'1234.23.4.2'.ipinfo.'1.0.0.1001'.info.city": 5, "'ipinfo'.'1.0.0.1001'.info.name.val.'city'": 6, "ipinfo.'1.0.0.1001'.info.city.'a.b.c'": 5,
func Sql ¶
Sql 构建sql
example:
sql := "select * from test where name=? and age =? order by ? limit ?" vs := []interface{}{ "hello", 1234, "id desc", "1,50", }
func SqlWhere ¶
构建where 条件
example:
sql := "name=? and age =? and cname in(?) and tname in(?)" vs := []interface{}{ "hello", 1234, []interface{}{ "a", "b", "c" }, []string{ "d", "e", "f" }, } SqlWhere(sql, vs...)
func StrToInt32 ¶
func Strtotime ¶
示例:
t, _ = Strtotime("-1 day", time.Now()) t, _ = Strtotime("-1 day", time.Now()) t, _ = Strtotime(" -1 month ", time.Now()) t, _ = Strtotime(" -1 year ", time.Now())
func UniqueKeys ¶
返回s1中每个元素 无法在s2中的检索到的值 eg : s1 = ["a" , "b" , "c"] ; s2 = ["a+t" , "b+t"] => ["c"]
func ValueFromPtr ¶
Types ¶
type MemDefine ¶
type MemDefine []*mem.VirtualMemoryStat