utils

package
v3.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 10 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindFiles

func FindFiles(folder string, recursive, followLinks bool, patterns ...string) ([]string, error)

FindFiles returns the list of the files matching the array of patterns

func FindFilesMaxDepth

func FindFilesMaxDepth(folder string, maxDepth int, followLinks bool, patterns ...string) ([]string, error)

FindFilesMaxDepth returns the list of the files matching the array of patterns

func FormatList

func FormatList(format string, args ...interface{}) collections.IGenericList

FormatList returns an array of string where format as been applied on every element of the supplied array

func GetCommandFromFile

func GetCommandFromFile(filename string, args ...interface{}) (cmd *exec.Cmd, err error)

GetCommandFromFile returns an exec.Cmd structure to run the supplied script file

func GetCommandFromString

func GetCommandFromString(script string, args ...interface{}) (cmd *exec.Cmd, tempFile string, err error)

GetCommandFromString returns an exec.Cmd structure to run the supplied command

func GetEnv

func GetEnv(varName, defaultValue string) string

GetEnv returns the environment variable value or defaultValue if it does not exist.

func GlobFunc

func GlobFunc(args ...interface{}) []string

GlobFunc returns an array of string representing the expansion of the supplied arguments using filepath.Glob function

func GlobFuncTrim

func GlobFuncTrim(args ...interface{}) []string

GlobFuncTrim returns an array of string representing the expansion of the supplied arguments using filepath.Glob function, it removes the unmatched arguments

func IsCommand

func IsCommand(command string) bool

IsCommand ensures that the supplied command does not contain any shell specific characters

func IsShebangScript

func IsShebangScript(content string) bool

IsShebangScript determines if the supplied code has a Shebang definition #! program subprogram

func IsTerraformFile

func IsTerraformFile(file string) bool

IsTerraformFile check if the file extension matches on of the terraform file extension

func Lorem

func Lorem(kind LoremKind, params ...int) (string, error)

Lorem generates random string using lorem ipsum generator

func MergeDictionaries

func MergeDictionaries(args ...map[string]interface{}) (map[string]interface{}, error)

MergeDictionaries merges multiple dictionaries into a single one prioritizing the first ones.

func MergeLists

func MergeLists(lists ...collections.IGenericList) collections.IGenericList

MergeLists return a single list from all supplied lists

func MustFindFiles

func MustFindFiles(folder string, recursive, followLinks bool, patterns ...string) []string

MustFindFiles returns the list of the files matching the array of patterns with panic on error

func MustFindFilesMaxDepth

func MustFindFilesMaxDepth(folder string, maxDepth int, followLinks bool, patterns ...string) []string

MustFindFilesMaxDepth returns the list of the files matching the array of patterns with panic on error

func Pwd

func Pwd() string

Pwd returns the current folder

func Relative

func Relative(folder, file string) string

Relative returns the relative path of file from folder

func ScriptParts

func ScriptParts(content string) (program, subprogram, source string)

ScriptParts splits up the supplied content into program, subprogram and source if the content matches Shebang defintion

func Substitute

func Substitute(content string, replacers ...RegexReplacer) string

Substitute actually applies the configured substituter

func TerraformFormat

func TerraformFormat(files ...string) error

TerraformFormat applies terraform fmt on

Types

type LoremKind

type LoremKind int

LoremKind represents the various Lorem Ipsum generator type

const (
	Word LoremKind
	Sentence
	Paragraph
	Host
	EMail
	URL
)

Constant used to describe the different kind of lorem generator

func GetLoremKind

func GetLoremKind(name string) (kind LoremKind, err error)

GetLoremKind converts a name to LoremKind

type RegexReplacer

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

RegexReplacer defines struct composed of one regular expression and its replacement string

func InitReplacers

func InitReplacers(replacers ...string) []RegexReplacer

InitReplacers configures the list of substitution that should be applied on each document

type String

type String = collections.String

String is simply an alias of collections.String

Jump to

Keyboard shortcuts

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