util

package
v0.0.0-...-757bf47 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToHumanReadable

func BytesToHumanReadable(b uint64) string

BytesToHumanReadable returns the converted human readable representation of the bytes.

func BytesToUint16

func BytesToUint16(b []byte) (v uint16)

BytesToUint16 convert bytes to uint64

func BytesToUint32

func BytesToUint32(b []byte) (v uint32)

BytesToUint32 convert bytes to uint32

func BytesToUint64

func BytesToUint64(b []byte) (v uint64)

BytesToUint64 convert bytes to uint64

func CheckFile

func CheckFile(filename string) (exists, canRead, canWrite bool, modTime time.Time, fileSize int64)

CheckFile checkfile

func CheckFileExists

func CheckFileExists(filename string) bool

CheckFileExists check file is exist

func FormatTime2String

func FormatTime2String(s string) string

FormatTime2String -

func GetBetweenDates

func GetBetweenDates(startdate, enddate string) []string

GetBetweenDates -

func GetBigFileLists

func GetBigFileLists(path string, arcfiles map[string]string, key string) error

GetBigFileLists -

func GetDaysDiffer

func GetDaysDiffer(from, to string) ([]string, int, error)

GetDaysDiffer -

func GetFileList

func GetFileList(path string, arcfiles map[string][]string, key string)

GetFileList -

func GetFileListName

func GetFileListName(path string, arcfiles map[string]string, key string) error

GetFileListName -

func GetFileListNamebyCreateTime

func GetFileListNamebyCreateTime(path string, key string) (string, error)

GetFileListNamebyCreateTime -

func GetFileSize

func GetFileSize(file *os.File) (size int64, err error)

GetFileSize get file size

func GetFileUIDGid

func GetFileUIDGid(fi os.FileInfo) (uid, gid uint32)

GetFileUIDGid return fileinfo

func GetHourDiffer

func GetHourDiffer(starttime, endtime string) (map[string][]string, int, error)

GetHourDiffer -

func GetLastCreateFile

func GetLastCreateFile(path string) string

GetLastCreateFile - get last create file name

func GetTDEngineHostName

func GetTDEngineHostName() (string, string)

GetTDEngineHostName Get TDEngien docker host name

func GetTimeRangeFromFileName

func GetTimeRangeFromFileName(filename string) (start, end time.Time, sensorid string, err error)

GetTimeRangeFromFileName -

func GzipData

func GzipData(input []byte, logger logging.ILogger) ([]byte, error)

GzipData return bytes

func GzipFile

func GzipFile(subdirectory, filepath, filename string, header, data []byte) error

GzipFile -

func HashStringToLong

func HashStringToLong(dir string) (v int64, err error)

HashStringToLong returns a 64 bit big int

func HashToInt32

func HashToInt32(data []byte) (v int32, err error)

HashToInt32 convert bytes to int32

func IsContainItem

func IsContainItem(items []string, item string) bool

IsContainItem -

func IsDigit

func IsDigit(str string) bool

IsDigit -

func IsGzippable

func IsGzippable(ext, mtype string, data []byte) bool

IsGzippable -

* Default more not to gzip since gzip can be done on client side.

func IsGzippableFileType

func IsGzippableFileType(ext, mtype string) (shouldBeZipped, iAmSure bool)

IsGzippableFileType return shouldbezipped & iamsure

* Default more not to gzip since gzip can be done on client side.

func IsZeroTime

func IsZeroTime(timestamp, timestamp2 time.Time, duration string, num int) bool

IsZeroTime 时间格式化: 零点,整小时,整分

func Join

func Join(names ...string) string

Join file operation

func Md5

func Md5(data []byte) (string, error)

Md5 check md5

func PathExists

func PathExists(path string) (bool, error)

PathExists -

func RemoveFolders

func RemoveFolders(dir string) error

RemoveFolders -

func SeekBigFileHeader

func SeekBigFileHeader(filename string, start, size int64) ([]byte, error)

SeekBigFileHeader -

func TestFolderWritable

func TestFolderWritable(folder string, logger logging.ILogger) (err error)

TestFolderWritable stat of folder

func TimeStringReplace

func TimeStringReplace(timer time.Time) string

TimeStringReplace -

func Uint16toBytes

func Uint16toBytes(b []byte, v uint16)

Uint16toBytes convert uint16 to bytes

func Uint32toBytes

func Uint32toBytes(b []byte, v uint32)

Uint32toBytes convert uint32 to bytes

func Uint64toBytes

func Uint64toBytes(b []byte, v uint64)

Uint64toBytes convert uint64 to bytes

func Uint8toBytes

func Uint8toBytes(b []byte, v uint8)

Uint8toBytes convert uint8 to bytes

func UnGzipData

func UnGzipData(input []byte, logger logging.ILogger) ([]byte, error)

UnGzipData return byte

func UnGzipFile

func UnGzipFile(filepath, filename string) error

UnGzipFile -

Types

type FullPath

type FullPath string

FullPath string

func JoinPath

func JoinPath(names ...string) FullPath

JoinPath file operation

func NewFullPath

func NewFullPath(dir, name string) FullPath

NewFullPath return full path

func (FullPath) AsInode

func (fp FullPath) AsInode() uint64

AsInode return HashStringToLong

func (FullPath) Child

func (fp FullPath) Child(name string) FullPath

Child -

func (FullPath) DirAndName

func (fp FullPath) DirAndName() (string, string)

DirAndName return dir and name

func (FullPath) Name

func (fp FullPath) Name() string

Name return file name

func (FullPath) Split

func (fp FullPath) Split() []string

Split split, but skipping the root

type MultiLocker

type MultiLocker struct {
	M   map[string]*sync.Mutex
	Smu sync.Mutex
}

MultiLocker -

func (*MultiLocker) Lock

func (l *MultiLocker) Lock(name string)

Lock -

func (*MultiLocker) Unlock

func (l *MultiLocker) Unlock(name string)

Unlock -

type Queue

type Queue struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Queue struct

func NewQueue

func NewQueue() *Queue

NewQueue return *Queue

func (*Queue) Dequeue

func (q *Queue) Dequeue() interface{}

Dequeue dequeue

func (*Queue) Enqueue

func (q *Queue) Enqueue(item interface{})

Enqueue enqueue

func (*Queue) Len

func (q *Queue) Len() int

Len return queue count

type WriteThrottler

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

WriteThrottler struct

func NewWriteThrottler

func NewWriteThrottler(bytesPerSecond int64) *WriteThrottler

NewWriteThrottler return *WriteThrottler

func (*WriteThrottler) MaybeSlowdown

func (wt *WriteThrottler) MaybeSlowdown(delta int64)

MaybeSlowdown -

Jump to

Keyboard shortcuts

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