utils

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2017 License: Apache-2.0 Imports: 19 Imported by: 77

Documentation

Index

Constants

View Source
const (
	GlobalKeyName = "name"
)

Variables

This section is empty.

Functions

func CreateDirIfNotExist

func CreateDirIfNotExist(dir string) (err error)

CreateDirIfNotExist 检查文件夹,不存在时创建

func GetEnv

func GetEnv(env string) string

parse ${ENV} to ENV get ENV value from os

func GetIdentifyIDByFile

func GetIdentifyIDByFile(f *os.File) (uint64, error)

func GetIdentifyIDByPath

func GetIdentifyIDByPath(path string) (uint64, error)

func GetRealPath

func GetRealPath(path string) (newPath string, fi os.FileInfo, err error)

GetRealPath 处理软链接等,找到文件真实路径

func IsJSON added in v1.3.3

func IsJSON(str string) bool

func MongoDail

func MongoDail(host string, mode string, syncTimeoutInS int64) (session *mgo.Session, err error)

------------------------------------------------------------------------

func ReadDirByTime

func ReadDirByTime(dir string) (files []os.FileInfo, err error)

ReadDirByTime 读取文件目录后按时间排序,时间最新的文件在前

func SetMode

func SetMode(s *mgo.Session, modeFriendly string, refresh bool)

func SortFilesByTime

func SortFilesByTime(files []os.FileInfo) (soredfiles []os.FileInfo)

SortFilesByTime 按照文件更新的unixnano从大到小排,即最新的文件在前

func TrimeList

func TrimeList(strs []string) (ret []string)

func TuoDecode

func TuoDecode(value []byte) (values [][]byte, err error)

TuoDecode 按照 TuoEncode的压缩算法解压,还原出[]byte数组。

func TuoEncode

func TuoEncode(values []sql.RawBytes) (ret []byte)

TuoEncode 把[]byte数组按照长度拼接到一起,每个sql.RawBytes之间间隔4个byte用于存储长度。

func WaitForInterrupt

func WaitForInterrupt(interrupt func())

Types

type Collection

type Collection struct {
	*mgo.Collection
}

func (Collection) CloseSession

func (c Collection) CloseSession() (err error)

type ErrorResponse added in v1.2.3

type ErrorResponse struct {
	Error error `json:"error"`
}

func NewErrorResponse added in v1.2.3

func NewErrorResponse(err error) *ErrorResponse

type File

type File struct {
	Info os.FileInfo
	Path string
}

func GetLogFiles

func GetLogFiles(doneFilePath string) (files []File)

type Int64Slice

type Int64Slice []int64

Int64Slice attaches the methods of Interface to []int64, sorting in decreasing order.

func (Int64Slice) Len

func (p Int64Slice) Len() int

func (Int64Slice) Less

func (p Int64Slice) Less(i, j int) bool

func (Int64Slice) Sort

func (p Int64Slice) Sort()

Sort is a convenience method.

func (Int64Slice) Swap

func (p Int64Slice) Swap(i, j int)

type KeyValue added in v1.2.3

type KeyValue struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type MongoConfig

type MongoConfig struct {
	Host           string `json:"host"`
	DB             string `json:"db"`
	Mode           string `json:"mode"`
	SyncTimeoutInS int64  `json:"timeout"` // 以秒为单位
	Direct         bool   `json:"direct"`
}

type OSInfo added in v1.3.2

type OSInfo struct {
	Kernel   string
	Core     string
	Platform string
	OS       string
	Hostname string
}

func GetOSInfo added in v1.3.2

func GetOSInfo() *OSInfo

func (*OSInfo) String added in v1.3.2

func (oi *OSInfo) String() string

type Option added in v1.2.3

type Option struct {
	KeyName       string
	ChooseOnly    bool
	ChooseOptions []string
	Default       string
	DefaultNoUse  bool
	Description   string
	CheckRegex    string
	Type          string `json:"Type,omitempty"`
}

type StatsError

type StatsError struct {
	StatsInfo
	ErrorDetail error `json:"error"`
	Ft          bool  `json:"-"`
	ErrorIndex  []int
}

func (*StatsError) AddErrors

func (se *StatsError) AddErrors()

func (*StatsError) AddSuccess

func (se *StatsError) AddSuccess()

func (*StatsError) Error

func (se *StatsError) Error() string

func (*StatsError) ErrorIndexIn

func (se *StatsError) ErrorIndexIn(idx int) bool

type StatsInfo

type StatsInfo struct {
	Errors    int64   `json:"errors"`
	Success   int64   `json:"success"`
	Speed     float64 `json:"speed"`
	Trend     string  `json:"trend"`
	LastError string  `json:"last_error"`
	Ftlag     int64   `json:"-"`
}

Jump to

Keyboard shortcuts

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