Documentation ¶
Index ¶
- Constants
- func Contains(list []string, element string) bool
- func ContainsPrefix(list []string, element string) bool
- func CreateAllDirectories(baseCacheDirectory string, versionNumber string) error
- func ErrorOf(_ any, err error) error
- func FindKeyCaseInsensitive(input map[string]string, key string) (string, bool)
- func FindValueCaseInsensitive(input map[string]string, key string) (string, bool)
- func GetTemporaryDirectory(baseCacheDirectory string, versionNumber string) string
- func IsSnykIde(environmentName string) bool
- func Merge(input1 []string, input2 []string) []string
- func Remove(input map[string]string, key string) map[string]string
- func RemoveSimilar(list []string, element string) []string
- func ToKeyValueMap(input []string, splitBy string) map[string]string
- func ToSlice(input map[string]string, combineBy string) []string
- func ValueOf[T any](value T, _ error) T
- type FileFilter
- type FileFilterOption
- type ToLog
- type ToZeroLogDebug
Constants ¶
const DIR_PERMISSION = 0755
0755 is the default permission for directories, it means the owner can read, write, and execute, and everyone else can read and execute but not write.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
Contains checks if a given string is in a given list of strings. Returns true if the element was found, false otherwise.
Example:
list := []string{"a", "b", "c"} element := "b" contains := Contains(list, element) // contains is true
func ContainsPrefix ¶
func CreateAllDirectories ¶
func ErrorOf ¶
ErrorOf is used to wrap a function call and extract the error out of it For example, in this code function Foo returns an error,
func Bar() (string, error){ // ... }
The Foo function can use ErrorOf to return the error from Bar:
func Foo() error{ return ErrorOf(Bar()) }
func FindKeyCaseInsensitive ¶
This method tries to find the given key is in the map. It searches different cases of the key:
- the exact match
- all lower case letters
- all upper case letters
If the key in any of these versions was found, it'll be returned alongside with a boolean indicating whether or not it was found.
Example:
map := {"a": "b", "c": "d"} key := "A" key, found = FindKeyCaseInsensitive(map, key) // key is "a" and found is true
func FindValueCaseInsensitive ¶
This method tries to find the given key is in the map and return its value. It searches different cases of the key:
- the exact match
- all lower case letters
- all upper case letters
If the key in any of these versions was found, its value will be returned alongside with a boolean indicating whether or not it was found.
Example:
map := {"a": "b", "c": "d"} key := "A" value, found = FindValueCaseInsensitive(map, key) // value is "b" and found is true
func GetTemporaryDirectory ¶
func Merge ¶
Merge merges two lists of strings and returns the result. The result will contain all elements from the first list and all elements from the second list which are not already in the first list.
Example:
list1 := []string{"a", "b", "c"} list2 := []string{"b", "c", "d"} mergedList := Merge(list1, list2) // mergedList is ["a", "b", "c", "d"]
func Remove ¶
Removes a given key from the input map and uses FindKeyCaseInsensitive() for this. The resulting map is being returned. If the key was not found, the input map will be returned.
Example:
map := {"a": "b", "c": "d"} key := "A" map = Remove(map, key) // map is {"c": "d"}
func RemoveSimilar ¶
RemoveSimilar removes all elements from the list which contain the given element. Returns the filtered list.
Example:
list := []string{"a", "b", "c"} element := "b" filteredList := RemoveSimilar(list, element) // filteredList is ["a", "c"]
func ToKeyValueMap ¶
ToKeyValueMap converts a list of strings to a map of strings. The input list will be converted based on the delimiter, 'splitBy'. The resulting map will contain the keys and values of the input list.
Example:
list := []string{"a=b", "c=d"} splitBy := "=" keyValueMap := ToKeyValueMap(list, splitBy) // keyValueMap is {"a": "b", "c": "d"}
func ToSlice ¶
ToSlice converts a map of strings to a list of strings. The keys and values will be combined by the given delimiter, 'combineBy'. The resulting list will contain the keys and values of the input map.
Example:
map := {"a": "b", "c": "d"} combineBy := "=" slice := ToSlice(map, combineBy) // slice is ["a=b", "c=d"]
Types ¶
type FileFilter ¶
type FileFilter struct {
// contains filtered or unexported fields
}
func NewFileFilter ¶
func NewFileFilter(path string, logger *zerolog.Logger, options ...FileFilterOption) *FileFilter
func (*FileFilter) GetAllFiles ¶
func (fw *FileFilter) GetAllFiles() chan string
GetAllFiles traverses a given dir path and fetches all filesToFilter in the directory
func (*FileFilter) GetFilteredFiles ¶
func (fw *FileFilter) GetFilteredFiles(filesCh chan string, globs []string) chan string
GetFilteredFiles returns a filtered channel of filepaths from a given channel of filespaths and glob patterns to filter on
type FileFilterOption ¶
type FileFilterOption func(*FileFilter) error
func WithThreadNumber ¶
func WithThreadNumber(maxThreadCount int) FileFilterOption
type ToLog ¶
ToLog is an io.Writer that can be used to write into a log.Logger, for example into an existing zerolog.Logger
type ToZeroLogDebug ¶
ToZeroLogDebug is an io.Writer that can be used for example with log.Logger to write to an existing zerolog writer