utils

package
v0.4.3-0...-fd7f253 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2018 License: GPL-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = logs.NewLogger()

Logger log

Functions

func AllKey

func AllKey(skmap map[string]interface{}) []string

AllKey return all key in map and sub map

func AllKeyRegexQuery

func AllKeyRegexQuery(filter string, sta interface{}) bson.M

AllKeyRegexQuery 为结构体定义所有key添加搜索模糊搜索条件

func AllStructKey

func AllStructKey(sta interface{}) []string

AllStructKey get all key in struct

func AnyHasSuffix

func AnyHasSuffix(s string, suffixlist []string) bool

AnyHasSuffix change HasSuffix function in any element

func BetweenIP

func BetweenIP(ipsrt1 string, ipstr2 string) []string

BetweenIP generate ip string from one to another

func DeleteElementInSlient

func DeleteElementInSlient(sl []string, s string) []string

DeleteElementInSlient as name

func DloadFilePath

func DloadFilePath(propath string) string

DloadFilePath relative dload path to abs path

func FindSub

func FindSub(strlist []string, str string) string

FindSub which one is my sun? input (["a", "b"],"ac") return "a"

func GenRsaKey

func GenRsaKey(bits int) error

GenRsaKey create key file

func GetCwd

func GetCwd() string

GetCwd return current path

func GetFileMD5Hash

func GetFileMD5Hash(filepath string) string

GetFileMD5Hash return MD5 hex string from file

func GetPassword

func GetPassword(key string) uint32

GetPassword create password like "google auth"

func GetValue

func GetValue(skmap map[string]interface{}, key string) interface{}

GetValue get value in map and sub map by key

func IP2Int

func IP2Int(ipnr net.IP) int64

IP2Int Convert net.IP to int64

func Int2IP

func Int2IP(ipnr int64) net.IP

Int2IP Convert uint to net.IP

func InterfaceSlice2BsonM

func InterfaceSlice2BsonM(slice []interface{}) []bson.M

InterfaceSlice2BsonM 对interface{}的切片进行类型转换

func IsDevMode

func IsDevMode() bool

IsDevMode is debug mode or not

func KeyDecode

func KeyDecode(encodeStr string) string

KeyDecode why?

func KeyEncode

func KeyEncode(key string) string

KeyEncode base64, why it need?

func KeyType

func KeyType(key string, value string) interface{}

KeyType change string to bool or int

func Last7DateStr

func Last7DateStr(timeformat string) []string

Last7DateStr get formated date string list in last seven day

func Loginit

func Loginit(logfile string)

Loginit as name

func MapSearch

func MapSearch(ml []bson.M, key string, value interface{}) map[string]interface{}

MapSearch Return a map by filter in a map list

func MapUpdate

func MapUpdate(ori map[string]interface{}, sub map[string]interface{}) map[string]interface{}

MapUpdate append a map to another

func Md5String

func Md5String(str string) string

Md5String return MD5 hex string from origin string

func NetIP2String

func NetIP2String(ip net.IP) string

NetIP2String Convert net.IP to string

func PPrintBsonM

func PPrintBsonM(obj interface{})

PPrintBsonM 把bson.M对象转化为人类可读的字符串

func PPrintMap

func PPrintMap(mlist ...map[string]interface{})

PPrintMap Petty Print Golang Map Struct

func ParseBsonM

func ParseBsonM(obj interface{}) string

ParseBsonM 把bson.M对象转化为人类可读的字符串

func RStrip

func RStrip(s string, suffixlist []string) string

RStrip emmm..

func RandStringBytesMaskImprSrc

func RandStringBytesMaskImprSrc(n int) string

RandStringBytesMaskImprSrc return random string

func ReverseStrList

func ReverseStrList(slice []string) []string

ReverseStrList Reverse a strings slice

func Round

func Round(f float64, n int) float64

Round float64

func SplitStrToMap

func SplitStrToMap(str string, sep1 string, sep2 string) map[string]string

SplitStrToMap Split string to map[string]string

func String2NetIP

func String2NetIP(ipstr string) net.IP

String2NetIP Convert string to net.IP

func StringInSlice

func StringInSlice(a string, list []string) bool

StringInSlice check string is a element of slice

func TCPAlive

func TCPAlive(server string) bool

TCPAlive check tcp alive

func ToBsonMSlice

func ToBsonMSlice(itf interface{}) []bson.M

ToBsonMSlice interface{} to []bson.M

func TodayRounded

func TodayRounded() time.Time

TodayRounded Get last midnight time

func ValueInListMap

func ValueInListMap(str string, listmap map[string][]string) string

Types

type ElasticSearch

type ElasticSearch struct {
	// contains filtered or unexported fields
}

ElasticSearch struct

func NewSession

func NewSession() ElasticSearch

NewSession init ElasticSearch obj

func (ElasticSearch) Count

func (es ElasticSearch) Count(indexs []string, query []byte) float64

Count count in es search

func (ElasticSearch) CountAllMonitor

func (es ElasticSearch) CountAllMonitor() float64

CountAllMonitor count all data in index monitor

func (ElasticSearch) LastSecMonitorData

func (es ElasticSearch) LastSecMonitorData(ip string, second int) interface{}

Last3SecMonitorData request /monitor/_search "gte":"now-ns"

func (ElasticSearch) Search

func (es ElasticSearch) Search(indexs []string, mode string, query []byte) bson.M

Search search by ElasticSearch web api

func (ElasticSearch) SearchByJSON

func (es ElasticSearch) SearchByJSON(indexs []string, query bson.M) bson.M

SearchByJSON call search by bson.M

func (ElasticSearch) SearchInMonitor

func (es ElasticSearch) SearchInMonitor(query []byte) bson.M

SearchInMonitor request /monitor/_search

type Paginator

type Paginator struct {
	Pagenum int
	Limit   int
}

Paginator : paginator struct

func (*Paginator) ToParameter

func (pa *Paginator) ToParameter() (int, int)

ToParameter return start and limit from Paginator

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL