cliutils

package module
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 24 Imported by: 0

README

English | 简体中文

Guance Cloud cliutils

This library mainly collects various common functional packages in the Guance Cloud. See the README of each package for details.

GoDoc MIT License

Documentation

Overview

Package cliutils host all public-used golang utils/tools/libs for Guance Cloud.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOssFileTooLarge = errors.New(`oss file too large`)

	DefaultPartSize = int64(32 * 1024 * 1024) //nolint:gomnd // 32MB
	DefaultTimeout  = uint(30)                //nolint:gomnd // seconds
	DefaultWorkers  = 8
)

Functions

func CreateRandomString

func CreateRandomString(n int) string

func Decrypt

func Decrypt(endata, phrase []byte) ([]byte, error)

func Encrypt

func Encrypt(data, phrase []byte) ([]byte, error)

func FloatEquals

func FloatEquals(a, b float64) bool

FloatEquals checks if two float64 numbers are "close enough".

func GZip

func GZip(data []byte) ([]byte, error)

func GZipStr

func GZipStr(str string) ([]byte, error)

func LeftStringTrim

func LeftStringTrim(s string, n int) string

func Md5Hash

func Md5Hash(data []byte) string

func MustGZip

func MustGZip(data []byte) []byte

func PromTextToMetrics

func PromTextToMetrics(data io.Reader, measurementPrefix, defaultMeasurement string, t time.Time) ([]*ifxcli.Point, error)

func SizeFmt

func SizeFmt(n int64) string

func StringTrim

func StringTrim(s string, n int) string

func ToUnsafeBytes

func ToUnsafeBytes(s string) (b []byte)

ToUnsafeBytes converts s to a byte slice without memory allocations. The returned byte slice is valid only until s is reachable and unmodified.

func ToUnsafeString

func ToUnsafeString(b []byte) string

ToUnsafeString converts b to string without memory allocations. The returned string is valid only until b is reachable and unmodified.

func WgWait

func WgWait(wg *sync.WaitGroup, timeout int)

func WhiteListMatched

func WhiteListMatched(val string, arr []*WhiteListItem) bool

func XID

func XID(p string) string

Types

type OssCli

type OssCli struct {
	Host, AccessKey, SecretKey, BucketName, WorkDir string
	Timeout                                         uint
	PartSize                                        int64
	Workers                                         int

	ReconnectCnt  int
	FailedCnt     int
	UploadedFiles int
	UploadedBytes int64
	// contains filtered or unexported fields
}

func (*OssCli) Download

func (oc *OssCli) Download(obj, to string) error

func (*OssCli) GetMeta

func (oc *OssCli) GetMeta(obj string) (map[string][]string, error)

func (*OssCli) Init

func (oc *OssCli) Init() error

func (*OssCli) ListObjects

func (oc *OssCli) ListObjects(prefix, marker string, maxKeys int) (oss.ListObjectsResult, error)

func (*OssCli) Move

func (oc *OssCli) Move(from, to string) error

func (*OssCli) Reconnect

func (oc *OssCli) Reconnect() error

func (*OssCli) SetMeta

func (oc *OssCli) SetMeta(obj string, meta map[string]string) error

func (*OssCli) Stat

func (oc *OssCli) Stat() string

func (*OssCli) Upload

func (oc *OssCli) Upload(from, to string) error

type Sem

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

func NewSem

func NewSem() *Sem

func (*Sem) Close

func (s *Sem) Close()

func (*Sem) Wait

func (s *Sem) Wait() <-chan interface{}

type WhiteListItem

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

WhiteListItem 白名单条目,支持普通字符串和正则表达式.

func NewWhiteListItem

func NewWhiteListItem(pattern string) *WhiteListItem

NewWhiteListItem 从字符串创建白名单条目,支持普通字符串和正则表达式.

func (*WhiteListItem) IsRegex

func (item *WhiteListItem) IsRegex() bool

func (*WhiteListItem) Match

func (item *WhiteListItem) Match(val string) bool

Match 检查给定路径是否与白名单条目匹配.

Directories

Path Synopsis
Package aggregate provides point aggregation and tail-sampling helpers.
Package aggregate provides point aggregation and tail-sampling helpers.
cmd
diskcache command
Package dialtesting defined dialtesting tasks and task implements.
Package dialtesting defined dialtesting tasks and task implements.
Package diskcache is a simple local-disk cache implements.
Package diskcache is a simple local-disk cache implements.
Code generated by goyacc -l -o gram_y.go gram.y.
Code generated by goyacc -l -o gram_y.go gram.y.
Package lineproto wraps influxdb lineprotocol.
Package lineproto wraps influxdb lineprotocol.
Package logger wrapped zap as a basic logging implement.
Package logger wrapped zap as a basic logging implement.
Package metrics implements datakit's Prometheus metrics
Package metrics implements datakit's Prometheus metrics
Package network wraps basic network related implements.
Package network wraps basic network related implements.
http
Package http wraps all HTTP releated common-used utils.
Package http wraps all HTTP releated common-used utils.
ws
Package ws wraps websocket implements among UNIX-like(Linux & macOS) platform
Package ws wraps websocket implements among UNIX-like(Linux & macOS) platform
Package otlp provides shared helpers for decoding OTLP payloads and converting common OTLP values into cliutils point primitives.
Package otlp provides shared helpers for decoding OTLP payloads and converting common OTLP values into cliutils point primitives.
pkg
hash
Package hash used to calculate hash
Package hash used to calculate hash
Package point implements datakits basic data structure.
Package point implements datakits basic data structure.
pb
test command
Package main used for GC escape:
Package main used for GC escape:
pprofparser
cfg
Package cfg is used to control the behavior of this package.
Package cfg is used to control the behavior of this package.
domain/events
Package events define the pprof event types.
Package events define the pprof event types.
domain/languages
Package languages define the supported languages.
Package languages define the supported languages.
domain/parameter
Package parameter defines the parsing parameters.
Package parameter defines the parsing parameters.
domain/pprof
Package pprof declares the pprof util methods.
Package pprof declares the pprof util methods.
domain/quantity
Package quantity defines the unit and quantity kinds.
Package quantity defines the unit and quantity kinds.
domain/tracing
Package tracing defines the trace and span entities.
Package tracing defines the trace and span entities.
service/parsing
Package parsing is the core pprof parsing package.
Package parsing is the core pprof parsing package.
service/storage
Package storage implements a series of storage kinds.
Package storage implements a series of storage kinds.
tools/filepathtoolkit
Package filepathtoolkit is a collection of filepath utils.
Package filepathtoolkit is a collection of filepath utils.
tools/jsontoolkit
Package jsontoolkit is a collection of json utils.
Package jsontoolkit is a collection of json utils.
tools/logtoolkit
Package logtoolkit is a collection of log utils.
Package logtoolkit is a collection of log utils.
tools/mathtoolkit
Package mathtoolkit is a collection of math utils.
Package mathtoolkit is a collection of math utils.
tools/parsetoolkit
Package parsetoolkit is a collection of parsing utils.
Package parsetoolkit is a collection of parsing utils.
Package system used to wrap basic system related settings.
Package system used to wrap basic system related settings.
rtpanic
Package rtpanic wraps panic handling during golang app panic.
Package rtpanic wraps panic handling during golang app panic.
Package testutil wraps basic tools when building goalng test cases.
Package testutil wraps basic tools when building goalng test cases.
Package tracer defined basic trace wraps.
Package tracer defined basic trace wraps.

Jump to

Keyboard shortcuts

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