utils

package
v0.0.0-...-472ff39 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendIfUnique

func AppendIfUnique(destination []string, value string) []string

func AppendUnique

func AppendUnique(destination []string, source []string) []string

func Contains

func Contains(list []string, x string) bool

Identifies whether the array 'list' contains the string 'x'.

func ContainsArg

func ContainsArg(cmd string, k string) bool

`cmd` is the command that will be executed Return true if it contains a reference to the argument expansion `arg`

func Die

func Die(err string, a ...interface{})

func Difference

func Difference(s []string, t []string) []string

return s after removing elements found in t

func Exit

func Exit(exitCode int, err string, a ...interface{})

Exit the program, printing a message to stderr. Deferred functions will not execute.

func Expand

func Expand(s string, mapping func(string) string) (res string)

Expand function is similar to os.Expand, with one difference: curly braces around variable names are compulsory - this only replaces recognized variable references. In particular, '$' followed by a character other than '{' will not be affected by expansion. E.g. "$a" will remain "$a" after expansion.

func Filter

func Filter(predicate func(string) bool, lists ...[]string) (ret []string)

func Find

func Find(a []string, x string) int

Find returns the smallest index i at which x == a[i], or -1 if there is no such index.

func FlattenPath

func FlattenPath(s string) string

FlattenPath produces a filename containing no slashes from a path.

func IsCompilableSource

func IsCompilableSource(s string) bool

IsCompilableSource checks if filename extension is a compiled one

func IsExecutable

func IsExecutable(fname string) bool

IsExecutable returns true if the given file exists and is executable

func IsHeader

func IsHeader(s string) bool

Does the input string look like it is a header file?

func IsNotCompilableSource

func IsNotCompilableSource(s string) bool

IsNotCompilableSource checks if filename extension isn't a compiled one

func IsNotHeader

func IsNotHeader(s string) bool

Does the input string look like it is a source file?

func Join

func Join(lists ...[]string) string

Join multiple lists of strings. This replaces appending multiple arrays together before calling strings.Join().

func ListsContain

func ListsContain(x string, lists ...[]string) bool

func MixedListToBobTargets

func MixedListToBobTargets(fileTargetList []string) []string

func MixedListToFiles

func MixedListToFiles(fileTargetList []string) []string

func NewStringSlice

func NewStringSlice(lists ...[]string) []string

NewStringSlice initialises a new slice from the input lists, which are concatenated. The in-built append function modifies the slice buffer of the existing slice. This means that using append has side-effect on the first list. The purpose of this function is to avoid those side-effects.

func PrefixAll

func PrefixAll(list []string, prefix string) []string

Prefixes a string to every item in a list

func PrefixDirs

func PrefixDirs(paths []string, dir string) []string

Prefixes a directory to every file in a list The returned file paths are the shortest paths (../ removed)

func Remove

func Remove(a []string, x string) []string

func Reversed

func Reversed(in []string) []string

Return a reversed a string array. This ought to be able to be done generically for any array type by using interfaces, but we only need to handle strings for now

func SortedKeys

func SortedKeys(m map[string]string) []string

func SortedKeysBoolMap

func SortedKeysBoolMap(m map[string]bool) []string

func SortedKeysByteSlice

func SortedKeysByteSlice(m map[string][]byte) []string

func SplitPath

func SplitPath(path string) (components []string)

func StripPrefixAll

func StripPrefixAll(list []string, prefix string) []string

Removes prefix from every item in the list

func StripUnusedArgs

func StripUnusedArgs(args map[string]string, cmd string)

cmd is the command that will be executed args contains potential argument that may occur in ${} This function will remove unused arguments from the map

func Trim

func Trim(args []string) []string

func Unique

func Unique(list []string) (ret []string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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