utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte     = 1
	Kilobyte = 1024 * Byte
	Megabyte = 1024 * Kilobyte
	Gigabyte = 1024 * Megabyte
	Terabyte = 1024 * Gigabyte
)

Variables

This section is empty.

Functions

func BooleanToInteger

func BooleanToInteger(value bool) int

BooleanToInteger converts a boolean value to an integer.

func ConvertFromStringToInteger

func ConvertFromStringToInteger(sizeStr string, targetUnit string) (int64, error)

ConvertFromStringToInteger converts a size string to an integer.

func ConvertToBytes

func ConvertToBytes(sizeStr string) (int64, error)

ConvertToBytes converts a size string to bytes.

func ConvertToGigabytes

func ConvertToGigabytes(sizeStr string) (int64, error)

ConvertToGigabytes converts a size string to gigabytes.

func ConvertToKilobytes

func ConvertToKilobytes(sizeStr string) (int64, error)

ConvertToKilobytes converts a size string to kilobytes.

func ConvertToMegabytes

func ConvertToMegabytes(sizeStr string) (int64, error)

ConvertToMegabytes converts a size string to megabytes.

func ConvertToTerabytes

func ConvertToTerabytes(sizeStr string) (int64, error)

ConvertToTerabytes converts a size string to terabytes.

func ExecuteCommand

func ExecuteCommand(command string, arguments ...string) (string, error)

ExecuteCommand executes a command and returns the output.

func ExpandHomeDir

func ExpandHomeDir(path string) (string, error)

ExpandHomeDir expands the home directory.

func GetCoreCount

func GetCoreCount() int

GetCoreCount returns the number of cores on the machine

func GetTotalMemory

func GetTotalMemory() uint64

GetTotalMemory returns the total memory on the machine

func IntegerToBoolean

func IntegerToBoolean(value int) bool

IntegerToBoolean converts an integer value to a boolean.

func IsInSameNetwork

func IsInSameNetwork(ip string, network string) bool

IsInSameNetwork checks if the given IP address is in the same network.

func IsNumeric

func IsNumeric(s string) bool

IsNumeric returns true if the string is numeric.

func IsValidIP

func IsValidIP(ip string) bool

IsValidIP checks if the given string is a valid IP.

func IsValidIPWithSubnet

func IsValidIPWithSubnet(address string) bool

IsValidIPWithSubnet checks if the given string is a valid IP with subnet.

func ParseSizeForFromStringToInteger

func ParseSizeForFromStringToInteger(sizeStr string) (int64, string, error)

ParseSizeForFromStringToInteger parses a size string to an integer.

func RemoveEmptyStringsFromSlice

func RemoveEmptyStringsFromSlice(slice []string) []string

RemoveEmptyStringsFromSlice removes empty strings from 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