helper

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 18 Imported by: 19

Documentation

Index

Constants

View Source
const (
	FlagPrefix         = "--"
	FlagValueSeparator = "="
)
View Source
const (
	AlphaNumeric = "1234567890abcdefghijklmnopqrstuvwxyz"
)

Helpers Constants

Variables

This section is empty.

Functions

func CheckEmptyStringAndStop

func CheckEmptyStringAndStop(e string)

CheckEmptyStringAndStop Checks if an error exist and stops the app

func CheckError

func CheckError(e error)

CheckError Checks if an error exist and calls panic

func CheckErrorAndStop

func CheckErrorAndStop(e error)

CheckErrorAndStop Checks if an error exist and stops the app

func Checksum added in v0.0.28

func Checksum(filePath string) (string, error)

func CopyDir

func CopyDir(src string, dst string) (err error)

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.

func CopyFile

func CopyFile(src, dst string) (err error)

func CreateDirectory added in v0.0.26

func CreateDirectory(folderPath string, mode fs.FileMode) bool

func DeleteAllFiles

func DeleteAllFiles(dir string) error

func DeleteFile

func DeleteFile(filePath string) error

func DirectoryExists added in v0.0.26

func DirectoryExists(folderPath string) bool

DirectoryExists Checks if a directory exists

func FileExists

func FileExists(path string) bool

FileExists Checks if a file/directory exists

func GetArgumentAt

func GetArgumentAt(index int) string

func GetCommandAt added in v0.0.28

func GetCommandAt(index int) string

func GetExecutionPath

func GetExecutionPath() string

GetExecutionPath gets executable path

func GetFlagArrayValue

func GetFlagArrayValue(flag string) []string

GetFlagArrayValue Gets a array of values of a flag from the command line arguments

func GetFlagSwitch

func GetFlagSwitch(flag string, defaultValue bool) bool

GetFlagSwitch Gets a switch value of a flag from the command line arguments

func GetFlagValue

func GetFlagValue(flag string, defaultValue string) string

GetFlagValue Gets a value of a flag from the command line arguments

func JoinPath

func JoinPath(items ...string) string

JoinPath combines strings into a full path

func MapFlagValue

func MapFlagValue(flag string) (string, string)

MapFlagValue Maps Keypair values from the flag

func RandomHex

func RandomHex(size int) string

RandomHex generates a random hex string

func RandomHexWithPrefix

func RandomHexWithPrefix(size int) string

RandomHexWithPrefix generates a random hex string

func RandomString

func RandomString(size int) string

RandomString generates a random string

func ReadFromFile

func ReadFromFile(filePath string) ([]byte, error)

func RemoveField added in v0.0.14

func RemoveField(obj interface{}, fields ...string) map[string]interface{}

func ToOsPath

func ToOsPath(path string) string

ToOsPath Converts a path into the native os path

func Untar

func Untar(src string, dst string) error

Untar takes a destination path and a reader; a tar reader loops over the tarfile creating the file structure at 'dst' along the way, and writing any files

func Unzip

func Unzip(src string, dest string) ([]string, error)

Unzip will decompress a zip archive, moving all files and folders within the zip file (parameter 1) to an output directory (parameter 2).

func WriteToFile

func WriteToFile(value string, filePath string) error

Types

type LogicState added in v0.0.16

type LogicState int64
const (
	Unknown LogicState = iota
	Enabled
	Disabled
)

func (LogicState) FromString added in v0.0.16

func (l LogicState) FromString(value string) LogicState

func (LogicState) String added in v0.0.16

func (l LogicState) String() string

type OperatingSystem

type OperatingSystem int

OperatingSystem enum

const (
	WindowsOs OperatingSystem = iota
	LinuxOs
	UnknownOs
)

Defines the operating system Enum

func GetOperatingSystem

func GetOperatingSystem() OperatingSystem

GetOperatingSystem returns the operating system

Get the operating system name and return it as an OperatingSystem constant.

Args:

None

Returns:

The operating system.

func (OperatingSystem) String

func (o OperatingSystem) String() string

type TestNestedStructure added in v0.0.10

type TestNestedStructure struct {
	TestFloat float32
	TestInt64 int64
}

type TestStructure added in v0.0.10

type TestStructure struct {
	TestString string
	TestBool   bool
	TestInt    int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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