utils

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Marshal = func(v interface{}) (io.Reader, error) {
	b, err := json.MarshalIndent(v, "", "\t")

	if err != nil {
		return nil, err
	}
	return bytes.NewReader(b), nil
}
View Source
var Unmarshal = func(r io.Reader, v interface{}) error {
	return json.NewDecoder(r).Decode(v)
}

Functions

func ColorizedPrettyPrint

func ColorizedPrettyPrint(data any)

func ContainsNonNumeric

func ContainsNonNumeric(s string) bool

ContainsNonNumeric

@brief:

ContainsNonNumeric check if there are non-numeric chars inside a given string

@params:

s - string - the string to check

@returns:

bool - true if contains chars, otherwise false

func DoesExist

func DoesExist(path string) bool

func FileExists

func FileExists(path string) bool

FileExists

@brief:

FileExists checks if a file exists

@params:

path - string - the path to check

@returns:

bool - true if exists, otherwise false

func GetAbsPath

func GetAbsPath(path string) string

GetAbsPath

@brief:

GetAbsPath finds the absolute path of an object

@params:

path - string - the path to fins abs of

@returns:

string - the absolute path

func GetCodeUntilMatchingBrace

func GetCodeUntilMatchingBrace(input string) string

GetCodeUntilMatchingBrace

@brief:

GetCodeUntilMatchingBrace returns the code until the next matching bracket

@params:

input string - the code as string to work on

@returns:

string - string with matching sets of brackets

func GetDirName

func GetDirName(path string) string

GetDirName

@brief:

GetDirName returns a file dir out of a given path

@params:

path - string - the path to get the dir path from

@returns:

string - the dir path

func GetFileContentAsBytes

func GetFileContentAsBytes(path string) ([]byte, error)

func GetFileName

func GetFileName(path string) string

GetFileName

@brief:

GetFileName returns a file name out of a given path

@params:

path - string - the path to get the file name from

@returns:

string - the file name

func GetFirstKeyInMap

func GetFirstKeyInMap(m map[string]interface{}) string

GetFirstKeyInMap

@brief:

GetFirstKeyInMap finds the first key in a map[string]interface{} object

@params:

m map[string]interface{} - the map to go over

@returns:

string - the first key, or "" if empty

func GetInput

func GetInput(message string) string

GetInput

@brief: GetInput will gets input from user and returns it @ @params: message string - the message to print to the user @ @returns: string - the input from the user

func IsDir

func IsDir(p string) bool

func IsHiddenObject

func IsHiddenObject(path string) bool

IsHiddenObject

@brief:

IsHiddenObject checks if a given folder / file is hidden

@params:

path - string - the path to check

@returns:

bool - true if hidden, otherwise false

func IsHiddenPath

func IsHiddenPath(path string) bool

IsHiddenPath

@brief:

IsHiddenPath checks if a given path is hidden

@params:

path - string - the path to check

@returns:

bool - true if hidden, otherwise false

func IsInitialized

func IsInitialized(dir string) bool

func IsItemInSlice

func IsItemInSlice(item string, items []string) bool

IsItemInSlice

@brief:

IsItemInSlice checks if a given item is inside a given slice

@params:

item - string - the item to look for
items - []string - the slice to look in

@returns:

bool - true if exists else false

func MustUnquote

func MustUnquote(str string) string

MustUnquote

@brief: MustUnquote get string input and returns it unquoted @ @params: str string - the string to unquote @ @returns: string - the new string

func PrettyPrintStruct

func PrettyPrintStruct(i interface{})

func PrintCharacterXTimes

func PrintCharacterXTimes(char string, times int)

PrintCharacterXTimes

@brief:

PrintCharacterXTimes prints a character a specified amount of time

@params:

char - string - the char to print
times - int - how many times to print

func RemoveLastDot

func RemoveLastDot(s string) string

RemoveLastDot

@brief:

RemoveLastDot removed the last dot form a sentence

@params:

s - string - the removed dot sentence

func StreamToByte

func StreamToByte(stream io.Reader) []byte

func StripProviderPrefix

func StripProviderPrefix(provider string) string

StripProviderPrefix

@brief:

StripProviderPrefix cleans the provider name from its registry prefix

@params:

provider - string - the provider to strip

@returns:

string - the stripped provide

Types

This section is empty.

Jump to

Keyboard shortcuts

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