utils

package
v0.0.0-...-8f5f446 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(srcPath string, destPath string) error

CopyFile copies the file from the source path to the destination path.

func DeserializeJson

func DeserializeJson(serializedJson string) (map[string]interface{}, error)

DeserializeJson deserializes a URL-encoded JSON string to a map.

func FileExists

func FileExists(filePath string) (bool, fs.FileInfo)

FileExists returns if the given path exists.

func GetEnvOrElse

func GetEnvOrElse(name, orElse string) string

GetEnvOrElse gets the value from the os environment or use the else value if variable is not present.

func IsDir

func IsDir(fileInfo fs.FileInfo) bool

IsDir returns if the given file is directory.

func IsDirAndWritable

func IsDirAndWritable(filePath string, fileInfo fs.FileInfo) (bool, error)

IsDirAndWritable checks if the file is a directory and is writable.

func IsDirEmpty

func IsDirEmpty(path string) (bool, error)

IsDirEmpty checks if a given directory is empty.

func IsSocket

func IsSocket(fileInfo fs.FileInfo) bool

IsSocket returns if the given file is a unix socket.

func IsValidDirName

func IsValidDirName(name string) bool

IsValidDirName checks if the given name is a valid dir name.

func IsValidRegistryAddress

func IsValidRegistryAddress(input string) bool

IsValidRegistryAddress checks if the input string is a valid registry address.

func IsValidTag

func IsValidTag(input string) bool

IsValidTag checks if the input string is a valid tag.

func IsWritable

func IsWritable(path string) (bool, error)

IsWritable checks if the directory at the given path is writable. Important: This function uses the unix package, which only works on unix systems.

func PrimaryIp

func PrimaryIp() (string, error)

func RandomString

func RandomString(length int, includeUpper bool, includeNumbers bool) string

RandomString generates a random string of a given length.

func SerializeJson

func SerializeJson(object map[string]interface{}) (string, error)

SerializeJson serializes a map to a URL-encoded JSON string.

func SetEnvVariables

func SetEnvVariables(variables map[string]string) error

SetEnvVariables sets variables to the os environment.

func Unzip

func Unzip(archivePath string, destPath string) error

Unzip extracts the zip archive to the destination path.

Types

type OsArch

type OsArch int32
const (
	Arch_Unknown OsArch = iota
	Arch_x86_64
	Arch_Arm_64
	Arch_Other
)

func DetectArchitecture

func DetectArchitecture() OsArch

DetectArchitecture detects the architecture of the system.

func (OsArch) String

func (o OsArch) String() string

String returns the string representation of the OsArch.

Jump to

Keyboard shortcuts

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