localio

package
v2.7.8 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AlphaTLDs = []string{}/* 1480 elements not displayed */

)

Functions

func AddPrefixToStrings added in v2.5.8

func AddPrefixToStrings(slice []string, prefix string) string

AddPrefixToStrings ...

func AptInstall added in v2.7.3

func AptInstall(packages *AptInstalled, aptName ...string) error

AptInstall ...

func CheckMatchInSlices

func CheckMatchInSlices(slice1, slice2 []string) bool

CheckMatchInSlices ...

func CheckSingleMatchInSlices added in v2.7.3

func CheckSingleMatchInSlices(slice1, slice2 []string) bool

CheckSingleMatchInSlices ...

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 ContainsWhitespace added in v2.5.8

func ContainsWhitespace(str string) bool

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 ExtractBaseDomain added in v2.6.3

func ExtractBaseDomain(target string) (string, error)

ExtractBaseDomain extracts the base domain from a given URL or DNS name

func FilePathWalkDir

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

FilePathWalkDir ...

func FirstToUpper added in v2.7.8

func FirstToUpper(s string) string

FirstToUpper ...

func FormatFindingName added in v2.7.8

func FormatFindingName(finding string) string

FormatFindingName ...

func FormatLibraryName added in v2.7.8

func FormatLibraryName(lib string) string

FormatLibraryName ...

func FormatStructToPrintableString added in v2.6.1

func FormatStructToPrintableString(s interface{}) string

func GetBaseDomain added in v2.5.8

func GetBaseDomain(domain string) string

GetBaseDomain gets a base domain without tld, ex. foobar.baz would return foobar. foo.bar.baz would return an empty string

func GetMatchedURLsStringsSlice added in v2.7.6

func GetMatchedURLsStringsSlice(urls, targets []string) []string

GetMatchedURLsStringsSlice ...

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 MergeStringSlice added in v2.5.8

func MergeStringSlice(slice1 []string, slice2 []string) []string

MergeStringSlice ...

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, logCommand bool) error

RunCommandPipeOutput runs a bash command and pipes the output to stdout and stderr in realtime also has a built-in timer that tracks execution duration. logCommand also functions as verbosity param. TODO add additional verbosity param it returns an error

func RunCommandsPipeOutput

func RunCommandsPipeOutput(commands []string, logCommand bool) error

RunCommandsPipeOutput ...

func SecondToUpper added in v2.7.8

func SecondToUpper(s string) string

SecondToUpper ...

func SliceContainsWords added in v2.6.2

func SliceContainsWords(slice1 []string, slice2 []string) bool

SliceContainsWords ...

func SortUnique added in v2.6.3

func SortUnique(slice []string) []string

SortUnique ...

func SplitStringIfContainsSpace added in v2.5.8

func SplitStringIfContainsSpace(input string) string

SplitStringIfContainsSpace ...

func TimeTrack

func TimeTrack(start time.Time, name string)

TimeTrack ...

func VersionGreaterOrEqual added in v2.6.9

func VersionGreaterOrEqual(versionString string, minVersionString string) bool

VersionGreaterOrEqual ...

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 AptInstalled added in v2.7.3

type AptInstalled struct {
	Name []string
}

AptInstalled ...

func NewAptInstalled added in v2.7.3

func NewAptInstalled() (*AptInstalled, error)

NewAptInstalled ...

type Client

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

func NewHTTPClient

func NewHTTPClient(skipVerify bool) *Client

NewHTTPClient ...

func (Client) DoReq

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

type LoadFromCommandOpts

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

type PipInstalled

type PipInstalled struct {
	Name     []string
	Versions PythonVersions
}

func NewPipInstalled

func NewPipInstalled() (*PipInstalled, error)

NewPipInstalled returns a slice of all the installed python3 pip packages

type PythonVersions added in v2.6.9

type PythonVersions struct {
	Python3Version string
	PipVersion     string
}

func GetPythonAndPipVersion added in v2.6.9

func GetPythonAndPipVersion() (*PythonVersions, error)

GetPythonAndPipVersion ...

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)

type Version added in v2.6.9

type Version struct {
	Major int
	Minor int
	Patch int
}

Jump to

Keyboard shortcuts

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