utils

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB = 1 << 10
	MB = 1 << 20
	GB = 1 << 30
	TB = 1 << 40
	PB = 1 << 50

	ErrInvalidSizeFormat = "invalid size format: %s"
	ErrInvalidSizeUnit   = "invalid size unit: %s"
)

Variables

View Source
var (
	ErrUnmarshal   = errors.New("unmarshal failed")
	ErrKeyNotFound = errors.New("key not found")
)

Functions

func ConvertSizeBytes

func ConvertSizeBytes(size string) (uint64, error)

ConvertSizeBytes converts a size string to bytes.

func FileExists

func FileExists(path string) bool

FileExists checks if a file exists at the given path.

func ParseLineDetail

func ParseLineDetail(line string) (key, value string)

FIXME Might go in another file ParseLineDetail parses a line of the show detail command and returns the key and value.

func SplitOutput

func SplitOutput(regularExpression *regexp.Regexp, output []byte) [][]byte

splitOutput splits the output into blocks based on the regular expression. TODO add tests.

func UnmarshalToPointer

func UnmarshalToPointer[T any](responseData json.RawMessage, key string) (*T, error)

UnmashalToPointer unmarshals a JSON response data to a pointer.

func UnmarshalToSlice

func UnmarshalToSlice[T any](responseData json.RawMessage, key string) ([]T, error)

UnmarshalToSlice unmarshals a JSON response data to a slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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