localio

package
v2.5.7 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckMatchInSlices

func CheckMatchInSlices(slice1, slice2 []string) bool

CheckMatchInSlices ...

func CheckStringInSlice

func CheckStringInSlice(slice []string, check string) bool

CheckStringInSlice ...

func CommandExists

func CommandExists(cmd string) (string, bool)

CommandExists ...

func ConfigureFlagOpts

func ConfigureFlagOpts(cmd *cobra.Command, lfcOpts *LoadFromCommandOpts) (interface{}, error)

ConfigureFlagOpts sets the cobra flag option to the LoadFromCommandOpts.Opts key it returns the parsed value of the cobra flag from LoadFromCommandOpts.Flag

func Contains

func Contains(s []string, str string) bool

Contains checks if a string exists within a slice

func CopyFile

func CopyFile(src, dest string) error

CopyFile ...

func CopyStringToFile

func CopyStringToFile(data, dest string) error

CopyStringToFile ...

func EmbedFileCopy

func EmbedFileCopy(src fs.File, dst string) error

EmbedFileCopy ...

func ExecCMD

func ExecCMD(command string, verbose bool) (string, error)

ExecCMD Execute a command

func Exists

func Exists(path string) (bool, error)

Exists returns whether the given file or directory exists

func FilePathWalkDir

func FilePathWalkDir(dirPath string) ([]string, error)

FilePathWalkDir ...

func GitClone

func GitClone(url, directory string) error

GitClone clones a public git repo url to directory

func GitCloneDepthOne

func GitCloneDepthOne(url, directory string) error

GitCloneDepthOne clones a public git repo url to directory

func Infof

func Infof(format string, args ...interface{})

Infof ...

func InstallPython3VirtualEnv

func InstallPython3VirtualEnv() error

InstallPython3VirtualEnv installs virtualenv via apt

func IsHeadless

func IsHeadless() bool

IsHeadless checks the DISPLAY env var to check if the server you're running this program on has a GUI / Desktop Environment

func IsRoot

func IsRoot() bool

IsRoot checks if the current user is root or not

func IsValidSubdomain

func IsValidSubdomain(sub string) bool

IsValidSubdomain checks if a string contains two or more dots and if it is a valid dns name

func Less

func Less(a, b string) bool

func LogError

func LogError(err error) error

LogError ...

func LogFatalf

func LogFatalf(format string, args ...interface{})

LogFatalf is a wrapper around gologger Fatal method

func LogInfo

func LogInfo(key, val, msg string)

LogInfo logs to a json file

func LogWarningf

func LogWarningf(format string, args ...interface{})

LogWarningf logs a warning to stdout

func PrependString

func PrependString(strs []string, s string) []string

func PrettyPrint

func PrettyPrint(v interface{}) (err error)

func PrintInfo

func PrintInfo(key, val, msg string)

PrintInfo is a wrapper around gologger Info method

func ReadLines

func ReadLines(path string) ([]string, error)

ReadLines reads a whole file into memory and returns a slice of its lines.

func RemoveDuplicateStr

func RemoveDuplicateStr(strSlice []string) []string

RemoveDuplicateStr removes duplicate strings from a slice of strings

func ResolveAbsPath

func ResolveAbsPath(path string) (string, error)

ResolveAbsPath ...

func RunCommandPipeOutput

func RunCommandPipeOutput(command string) error

RunCommandPipeOutput runs a bash command and pipes the output to stdout in realtime also has a built-in timer that tracks execution duration it returns an error

func RunCommandsPipeOutput

func RunCommandsPipeOutput(commands []string) error

RunCommandsPipeOutput ...

func TimeTrack

func TimeTrack(start time.Time, name string)

TimeTrack ...

func WriteLines

func WriteLines(lines []string, path string) error

WriteLines writes the lines to the given file.

func WriteStringToFile

func WriteStringToFile(outputFile, data string) error

WriteStringToFile writes a string to a file

func WriteStructToJSONFile

func WriteStructToJSONFile(data interface{}, outputFile string) error

WriteStructToJSONFile ...

func WriteToCSVAndJSONFiles

func WriteToCSVAndJSONFiles(data map[string][]string, fileName string) error

WriteToCSVAndJSONFiles ...

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewHTTPClient

func NewHTTPClient() *Client

func (Client) DoReq

func (c Client) DoReq(u, method string, target interface{}, headers map[string]string, params map[string]string) error

type LoadFromCommandOpts

type LoadFromCommandOpts struct {
	DefaultFlagVal string
	Flag           string
	IsFilePath     bool
	Prefix         string
	Opts           interface{}
}

type PipInstalled

type PipInstalled struct {
	Name []string
}

func NewPipInstalled

func NewPipInstalled() (*PipInstalled, error)

NewPipInstalled returns a slice of all the installed python3 pip packages

type StringSlice

type StringSlice []string

StringSlice attaches the methods of Interface to []string, sorting in increasing order using natural order.

func (StringSlice) Len

func (p StringSlice) Len() int

func (StringSlice) Less

func (p StringSlice) Less(i, j int) bool

func (StringSlice) Swap

func (p StringSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

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