utils

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchContentFromUrl added in v0.1.11

func FetchContentFromUrl(u string) ([]byte, error)

FetchContentFromUrl fetches the content from a url and returns its bytes.

func FileContains added in v0.2.0

func FileContains(loc string, match string) (bool, error)

func FindFiles

func FindFiles(root, pattern string, excludePattern string, skipDir []string) ([]string, error)

FindFiles scans a directory for files matching the provided pattern. excludePattern can be used to ignore files using regex, and a list of directories can be skipped using skipDir.

func Glob added in v0.2.0

func Glob(dir string, match string) ([]string, error)

func HasComposerDependency added in v0.2.0

func HasComposerDependency(loc string, deps []string) (bool, error)

func IntSliceContains added in v0.1.14

func IntSliceContains(slice []int, item int) bool

IntSliceContains determines whether an item exists in a slice of int.

func IsDirectory added in v0.2.0

func IsDirectory(path string) (bool, error)

func IsFileInDirs added in v0.1.17

func IsFileInDirs(root string, file string, dirs []string) bool

IsFileInDirs determines whether a file is in a list of directories. root is assumed to be a reference directory, file is the file path with the root prefixed and dirs is a list of relative paths from the root.

func LookupYamlPath added in v0.1.14

func LookupYamlPath(n *yaml.Node, path string) ([]*yaml.Node, error)

LookupYamlPath attempts to query Yaml data using a JSONPath query and returns the found Node. It uses the implemention by https://github.com/vmware-labs/yaml-jsonpath.

func MergeBoolPtrs added in v0.1.14

func MergeBoolPtrs(boolA *bool, boolB *bool)

MergeBoolPtrs compares two bool pointers and replaces boolA with boolB if the latter is non-nil.

func MergeIntSlice added in v0.1.16

func MergeIntSlice(slcA *[]int, slcB []int)

MergeIntSlice replaces the values of a int slice with those of another.

func MergeString added in v0.1.14

func MergeString(strA *string, strB string)

MergeString compares two strings and replaces strA with strB if the latter is not empty.

func MergeStringSlice added in v0.1.14

func MergeStringSlice(slcA *[]string, slcB []string)

MergeStringSlice replaces the values of a string slice with those of another.

func PackageCheckString added in v0.3.0

func PackageCheckString(slice []string, item string, item_version string) bool

Sift through a slice to determine if it contains eligible package with optional version constrains.

func SliceContains added in v0.3.0

func SliceContains(slice any, item any) bool

SliceContains determines whether an item exists in a slice of any type.

func StringIsUrl added in v0.1.11

func StringIsUrl(s string) bool

StringIsUrl determines whether a string is a url by trying to parse it.

func StringSliceContains

func StringSliceContains(slice []string, item string) bool

StringSliceContains determines whether an item exists in a slice of string.

func StringSliceMatch added in v0.1.14

func StringSliceMatch(slice []string, item string) bool

func StringSlicesInterdiff added in v0.3.0

func StringSlicesInterdiff(slc1 []string, slc2 []string) []string

StringSlicesInterdiff returns the strings in slc2 that do not present in slc1.

func StringSlicesInterdiffUnique added in v0.3.0

func StringSlicesInterdiffUnique(slc1, slc2 []string) []string

StringSlicesInterdiffUnique returns the unique strings in slc2 that do not present in slc1.

func StringSlicesIntersect

func StringSlicesIntersect(slc1 []string, slc2 []string) []string

StringSlicesIntersect finds the intersection between two slices of string.

func StringSlicesIntersectUnique added in v0.3.0

func StringSlicesIntersectUnique(slc1, slc2 []string) []string

StringSlicesIntersectUnique returns the unique strings in slc2 that also present in slc1.

Types

This section is empty.

Jump to

Keyboard shortcuts

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