utility

package
v0.0.0-...-1097c9b Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB = 1024
	MB = KB * 1024
	GB = MB * 1024
	TB = GB * 1024
)

Variables

This section is empty.

Functions

func BlueString

func BlueString(s string) string

func EncodedUserdata

func EncodedUserdata(content string) string

func Filter

func Filter[T any](items []T, filterFun func(x T) bool) []T

func GetAllIpaddress

func GetAllIpaddress() ([]string, error)

func GetStructTags

func GetStructTags(i interface{}) []string

func GreenString

func GreenString(s string) string

func LoadUserData

func LoadUserData(file string) (string, error)

func LogError

func LogError(err error, message string, exit bool)

func LogIfError

func LogIfError(err error, exit bool, format string, args ...interface{})

func MatchPingResult

func MatchPingResult(text string) []string

func OneOfBoolean

func OneOfBoolean(values ...bool) bool

func OneOfNumber

func OneOfNumber[T int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | float32 | float64](values ...T) T

func OneOfString

func OneOfString(strs ...string) string

func OneOfStringArrays

func OneOfStringArrays(arraysList ...[]string) []string

func RaiseIfError

func RaiseIfError(err error, msg string)

func RedString

func RedString(s string) string

func Retry

func Retry(condition RetryCondition, function func() bool) error

func RetryError

func RetryError(condition RetryCondition, function func() (bool, error)) error

func RetryWithContext

func RetryWithContext(ctx context.Context, condition RetryCondition, function func() error) error

func RetryWithErrors

func RetryWithErrors(condition RetryCondition, matchErrors []string, function func() error) error

func Split

func Split(s string, sep string) []string

func Sum

func Sum[T int | int32 | int64 | float32 | float64](numbers ...T) T

func UnmarshalJsonKey

func UnmarshalJsonKey(bytes []byte, key string, v any) error

func UrlJoin

func UrlJoin(path ...string) string

func UrlValues

func UrlValues(m map[string]string) url.Values

func VersionUrl

func VersionUrl(endpoint, version string) string

func WatchFileSize

func WatchFileSize(filePath string, size int)

Types

type ActionNotFinishedError

type ActionNotFinishedError ErrArgs

func NewActionNotFinishedError

func NewActionNotFinishedError(args ...interface{}) ActionNotFinishedError

func (ActionNotFinishedError) Error

func (e ActionNotFinishedError) Error() string

type ColorFormater

type ColorFormater struct {
	Green  []string
	Yellow []string
	Red    []string
}

type ColorStatus

type ColorStatus struct {
	Formater ColorFormater
	// contains filtered or unexported fields
}

func NewColorStatus

func NewColorStatus(s string) ColorStatus

func (ColorStatus) String

func (s ColorStatus) String() string

type DefaultInterval

type DefaultInterval struct {
	Interval time.Duration
}

func (DefaultInterval) Next

func (i DefaultInterval) Next() time.Duration

type ErrArgs

type ErrArgs struct {
	Args []interface{}
}

type GuestHasNoIpaddressError

type GuestHasNoIpaddressError ErrArgs

func NewGuestHasNoIpaddressError

func NewGuestHasNoIpaddressError(ipAddress []string) GuestHasNoIpaddressError

func (GuestHasNoIpaddressError) Error

func (e GuestHasNoIpaddressError) Error() string

type GuestNoIpaddressError

type GuestNoIpaddressError ErrArgs

func NewGuestNoIpaddressError

func NewGuestNoIpaddressError() GuestNoIpaddressError

func (GuestNoIpaddressError) Error

func (e GuestNoIpaddressError) Error() string

type ImageNotActive

type ImageNotActive ErrArgs

func NewImageNotActiveError

func NewImageNotActiveError(imageId string) ImageNotActive

func (ImageNotActive) Error

func (e ImageNotActive) Error() string

type Interval

type Interval interface {
	Next() time.Duration
}

type PingLossPackage

type PingLossPackage ErrArgs

func NewPingLossPackage

func NewPingLossPackage(lossed int) PingLossPackage

func (PingLossPackage) Error

func (e PingLossPackage) Error() string

type ReaderWithProcess

type ReaderWithProcess struct {
	io.Reader
	Bar *pb.ProgressBar
}

func NewProcessReader

func NewProcessReader(reader io.ReadCloser, size int) *ReaderWithProcess

func (*ReaderWithProcess) Read

func (reader *ReaderWithProcess) Read(p []byte) (int, error)

type RetryCondition

type RetryCondition struct {
	Timeout      time.Duration
	IntervalMin  time.Duration
	IntervalMax  time.Duration
	IntervalStep time.Duration
	// contains filtered or unexported fields
}

func (*RetryCondition) NextInterval

func (c *RetryCondition) NextInterval() time.Duration

type ServerNotBooted

type ServerNotBooted ErrArgs

func NewServerNotBootedError

func NewServerNotBootedError(serverId string) ServerNotBooted

func (ServerNotBooted) Error

func (e ServerNotBooted) Error() string

type ServerNotStopped

type ServerNotStopped ErrArgs

func NewServerNotStopped

func NewServerNotStopped(serverId string) ServerNotStopped

func (ServerNotStopped) Error

func (e ServerNotStopped) Error() string

type SnapshotIsNotAvailable

type SnapshotIsNotAvailable ErrArgs

func NewSnapshotIsNotAvailable

func NewSnapshotIsNotAvailable(snapshotId string) SnapshotIsNotAvailable

func (SnapshotIsNotAvailable) Error

func (e SnapshotIsNotAvailable) Error() string

type StepInterval

type StepInterval struct {
	Min  time.Duration
	Max  time.Duration
	Step time.Duration
	// contains filtered or unexported fields
}

func (*StepInterval) Next

func (i *StepInterval) Next() time.Duration

type StringRing

type StringRing struct {
	Items []string
	// contains filtered or unexported fields
}

func (*StringRing) Next

func (r *StringRing) Next() string

func (*StringRing) Sample

func (r *StringRing) Sample(count int) []string

type VolumeHasTaskError

type VolumeHasTaskError ErrArgs

func NewVolumeHasTaskError

func NewVolumeHasTaskError(volumeId string) VolumeHasTaskError

func (VolumeHasTaskError) Error

func (e VolumeHasTaskError) Error() string

Jump to

Keyboard shortcuts

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