utils

package
v6.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MegaBytes  = "MB"
	GigaBytes  = "GB"
	TerraBytes = "TB"
	PetaBytes  = "PB"
)
View Source
const (
	Seconds = "s"
	Minutes = "m"
	Hours   = "h"
	Days    = "D"
	Months  = "M"
	Years   = "Y"
)

Variables

This section is empty.

Functions

func ConvertSize

func ConvertSize(sizeToConvert, unitToConvertTo string) (int, error)

ConvertSize converts the specified size to the unit specified Right now, it has support for MB, GB

func ConvertTime added in v6.8.0

func ConvertTime(timeToConvert, unitToConvertTo string) (int, error)

func ConvertToGB

func ConvertToGB(size, unit string) (int, error)

func ConvertToMB

func ConvertToMB(size, unit string) (int, error)

func GetPropertiesKVSet

func GetPropertiesKVSet(i interface{}) map[string]interface{}

GetPropertiesKVSet converts a struct to a map[string]interface{}. It will only include fields that are set and are not nil. It will also recursively convert any nested structs.

	type MyStruct struct {
	    Field1 int
	    Field2 string
	}

  instance := MyStruct{Field1: 42, Field2: "Hello"}
  result := GetPropertiesKVSet(instance) // map[string]interface{}{"Field1": 42, "Field2": "Hello"}

func ParseDate added in v6.8.0

func ParseDate(strDate string) (time.Time, error)

ParseDate parses a date string in RFC3339 format and returns a time.Time object It also removes the [UTC] suffix if present

func ReadPublicKey

func ReadPublicKey(path string) (key string, err error)

ReadPublicKey from a specific path

func ValidateIPv6CidrBlockAgainstParentCidrBlock

func ValidateIPv6CidrBlockAgainstParentCidrBlock(cidr string, expectedMask int, parentCidr string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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