common

package
v0.0.0-...-342a630 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UTF8      = "utf8"
	GBK       = "gbk"
	GB2312    = "gb2312"
	ISOLatin1 = "ios-8859-1"
)

Variables

View Source
var (
	ErrLines = errors.New("not correct line format")
)
View Source
var (
	ErrUnSupportFormat = errors.New("unsupported time format")
)

Functions

func CompressToGzipFile

func CompressToGzipFile(srcPath, dstPath string) error

func CpuLoad1Usage

func CpuLoad1Usage() float64

func CurrentLocalIP

func CurrentLocalIP() string

func DiskUsagePercent

func DiskUsagePercent() float64

func EnsureDirExist

func EnsureDirExist(path string) error

func Have

func Have(path string) bool

func HaveDir

func HaveDir(file string) bool

func IsUUID

func IsUUID(sid string) bool

func LookupCharsetDecode

func LookupCharsetDecode(charset string) transform.Transformer

func LookupCharsetEncode

func LookupCharsetEncode(charset string) transform.Transformer

func MemoryUsagePercent

func MemoryUsagePercent() float64

func ParseMemLimit

func ParseMemLimit(lines []string) (uint64, error)

func ParseMemUsage

func ParseMemUsage(lines []string) (uint64, error)

func RandomStr

func RandomStr(length int) string

func ReadFileLines

func ReadFileLines(path string) ([]string, error)

func UUID

func UUID() string

Types

type Mem

type Mem struct {
	LimitUsage uint64
	Usage      uint64

	Stats MemStat
}

func CGroupMem

func CGroupMem() (Mem, error)

func (Mem) MemUsageNoCache

func (m Mem) MemUsageNoCache() float64

func (Mem) Percent

func (m Mem) Percent() float64

type MemStat

type MemStat map[string]uint64

func ParseMemStat

func ParseMemStat(lines []string) (MemStat, error)

type UTCTime

type UTCTime struct {
	time.Time
}

func NewNowUTCTime

func NewNowUTCTime() UTCTime

func NewUTCTime

func NewUTCTime(now time.Time) UTCTime

func (UTCTime) MarshalJSON

func (t UTCTime) MarshalJSON() ([]byte, error)

func (*UTCTime) UnmarshalJSON

func (t *UTCTime) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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